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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 926193003: Move rendering/RenderBox to layout/LayoutBox. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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/core/dom/Element.h ('k') | Source/core/dom/Fullscreen.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) 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) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 document().updateLayoutIgnorePendingStylesheets(); 557 document().updateLayoutIgnorePendingStylesheets();
558 if (LayoutObject* renderer = this->renderer()) 558 if (LayoutObject* renderer = this->renderer())
559 return renderer->offsetParent(); 559 return renderer->offsetParent();
560 return nullptr; 560 return nullptr;
561 } 561 }
562 562
563 int Element::clientLeft() 563 int Element::clientLeft()
564 { 564 {
565 document().updateLayoutIgnorePendingStylesheets(); 565 document().updateLayoutIgnorePendingStylesheets();
566 566
567 if (RenderBox* renderer = renderBox()) 567 if (LayoutBox* renderer = layoutBox())
568 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft() ), *renderer); 568 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft() ), *renderer);
569 return 0; 569 return 0;
570 } 570 }
571 571
572 int Element::clientTop() 572 int Element::clientTop()
573 { 573 {
574 document().updateLayoutIgnorePendingStylesheets(); 574 document().updateLayoutIgnorePendingStylesheets();
575 575
576 if (RenderBox* renderer = renderBox()) 576 if (LayoutBox* renderer = layoutBox())
577 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientTop()) , *renderer); 577 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientTop()) , *renderer);
578 return 0; 578 return 0;
579 } 579 }
580 580
581 int Element::clientWidth() 581 int Element::clientWidth()
582 { 582 {
583 document().updateLayoutIgnorePendingStylesheets(); 583 document().updateLayoutIgnorePendingStylesheets();
584 584
585 // When in strict mode, clientWidth for the document element should return t he width of the containing frame. 585 // When in strict mode, clientWidth for the document element should return t he width of the containing frame.
586 // When in quirks mode, clientWidth for the body element should return the w idth of the containing frame. 586 // When in quirks mode, clientWidth for the body element should return the w idth of the containing frame.
587 bool inQuirksMode = document().inQuirksMode(); 587 bool inQuirksMode = document().inQuirksMode();
588 if ((!inQuirksMode && document().documentElement() == this) 588 if ((!inQuirksMode && document().documentElement() == this)
589 || (inQuirksMode && isHTMLElement() && document().body() == this)) { 589 || (inQuirksMode && isHTMLElement() && document().body() == this)) {
590 if (FrameView* view = document().view()) { 590 if (FrameView* view = document().view()) {
591 if (RenderView* renderView = document().renderView()) 591 if (RenderView* renderView = document().renderView())
592 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width( ), *renderView); 592 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width( ), *renderView);
593 } 593 }
594 } 594 }
595 595
596 if (RenderBox* renderer = renderBox()) 596 if (LayoutBox* renderer = layoutBox())
597 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth (), *renderer).round(); 597 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth (), *renderer).round();
598 return 0; 598 return 0;
599 } 599 }
600 600
601 int Element::clientHeight() 601 int Element::clientHeight()
602 { 602 {
603 document().updateLayoutIgnorePendingStylesheets(); 603 document().updateLayoutIgnorePendingStylesheets();
604 604
605 // When in strict mode, clientHeight for the document element should return the height of the containing frame. 605 // When in strict mode, clientHeight for the document element should return the height of the containing frame.
606 // When in quirks mode, clientHeight for the body element should return the height of the containing frame. 606 // When in quirks mode, clientHeight for the body element should return the height of the containing frame.
607 bool inQuirksMode = document().inQuirksMode(); 607 bool inQuirksMode = document().inQuirksMode();
608 608
609 if ((!inQuirksMode && document().documentElement() == this) 609 if ((!inQuirksMode && document().documentElement() == this)
610 || (inQuirksMode && isHTMLElement() && document().body() == this)) { 610 || (inQuirksMode && isHTMLElement() && document().body() == this)) {
611 if (FrameView* view = document().view()) { 611 if (FrameView* view = document().view()) {
612 if (RenderView* renderView = document().renderView()) 612 if (RenderView* renderView = document().renderView())
613 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height (), *renderView); 613 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height (), *renderView);
614 } 614 }
615 } 615 }
616 616
617 if (RenderBox* renderer = renderBox()) 617 if (LayoutBox* renderer = layoutBox())
618 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh t(), *renderer).round(); 618 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh t(), *renderer).round();
619 return 0; 619 return 0;
620 } 620 }
621 621
622 double Element::scrollLeft() 622 double Element::scrollLeft()
623 { 623 {
624 document().updateLayoutIgnorePendingStylesheets(); 624 document().updateLayoutIgnorePendingStylesheets();
625 625
626 if (document().documentElement() != this) { 626 if (document().documentElement() != this) {
627 if (RenderBox* rend = renderBox()) 627 if (LayoutBox* box = layoutBox())
628 return adjustScrollForAbsoluteZoom(rend->scrollLeft(), *rend); 628 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box);
629 return 0; 629 return 0;
630 } 630 }
631 631
632 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 632 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
633 if (document().inQuirksMode()) 633 if (document().inQuirksMode())
634 return 0; 634 return 0;
635 635
636 if (LocalDOMWindow* window = document().domWindow()) 636 if (LocalDOMWindow* window = document().domWindow())
637 return window->scrollX(); 637 return window->scrollX();
638 } 638 }
639 639
640 return 0; 640 return 0;
641 } 641 }
642 642
643 double Element::scrollTop() 643 double Element::scrollTop()
644 { 644 {
645 document().updateLayoutIgnorePendingStylesheets(); 645 document().updateLayoutIgnorePendingStylesheets();
646 646
647 if (document().documentElement() != this) { 647 if (document().documentElement() != this) {
648 if (RenderBox* rend = renderBox()) 648 if (LayoutBox* box = layoutBox())
649 return adjustScrollForAbsoluteZoom(rend->scrollTop(), *rend); 649 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box);
650 return 0; 650 return 0;
651 } 651 }
652 652
653 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 653 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
654 if (document().inQuirksMode()) 654 if (document().inQuirksMode())
655 return 0; 655 return 0;
656 656
657 if (LocalDOMWindow* window = document().domWindow()) 657 if (LocalDOMWindow* window = document().domWindow())
658 return window->scrollY(); 658 return window->scrollY();
659 } 659 }
660 660
661 return 0; 661 return 0;
662 } 662 }
663 663
664 void Element::setScrollLeft(double newLeft) 664 void Element::setScrollLeft(double newLeft)
665 { 665 {
666 document().updateLayoutIgnorePendingStylesheets(); 666 document().updateLayoutIgnorePendingStylesheets();
667 667
668 if (std::isnan(newLeft)) 668 if (std::isnan(newLeft))
669 return; 669 return;
670 670
671 if (document().documentElement() != this) { 671 if (document().documentElement() != this) {
672 RenderBox* rend = renderBox(); 672 LayoutBox* box = layoutBox();
673 if (rend) 673 if (box)
674 rend->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * rend->style ()->effectiveZoom())); 674 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style() ->effectiveZoom()));
675 return; 675 return;
676 } 676 }
677 677
678 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 678 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
679 if (document().inQuirksMode()) 679 if (document().inQuirksMode())
680 return; 680 return;
681 681
682 if (LocalDOMWindow* window = document().domWindow()) 682 if (LocalDOMWindow* window = document().domWindow())
683 window->scrollTo(newLeft, window->scrollY()); 683 window->scrollTo(newLeft, window->scrollY());
684 } 684 }
685 } 685 }
686 686
687 void Element::setScrollTop(double newTop) 687 void Element::setScrollTop(double newTop)
688 { 688 {
689 document().updateLayoutIgnorePendingStylesheets(); 689 document().updateLayoutIgnorePendingStylesheets();
690 690
691 if (std::isnan(newTop)) 691 if (std::isnan(newTop))
692 return; 692 return;
693 693
694 if (document().documentElement() != this) { 694 if (document().documentElement() != this) {
695 RenderBox* rend = renderBox(); 695 LayoutBox* box = layoutBox();
696 if (rend) 696 if (box)
697 rend->setScrollTop(LayoutUnit::fromFloatRound(newTop * rend->style() ->effectiveZoom())); 697 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()-> effectiveZoom()));
698 return; 698 return;
699 } 699 }
700 700
701 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 701 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
702 if (document().inQuirksMode()) 702 if (document().inQuirksMode())
703 return; 703 return;
704 704
705 if (LocalDOMWindow* window = document().domWindow()) 705 if (LocalDOMWindow* window = document().domWindow())
706 window->scrollTo(window->scrollX(), newTop); 706 window->scrollTo(window->scrollX(), newTop);
707 } 707 }
708 } 708 }
709 709
710 int Element::scrollWidth() 710 int Element::scrollWidth()
711 { 711 {
712 document().updateLayoutIgnorePendingStylesheets(); 712 document().updateLayoutIgnorePendingStylesheets();
713 if (RenderBox* rend = renderBox()) 713 if (LayoutBox* box = layoutBox())
714 return adjustLayoutUnitForAbsoluteZoom(rend->scrollWidth(), *rend).toDou ble(); 714 return adjustLayoutUnitForAbsoluteZoom(box->scrollWidth(), *box).toDoubl e();
715 return 0; 715 return 0;
716 } 716 }
717 717
718 int Element::scrollHeight() 718 int Element::scrollHeight()
719 { 719 {
720 document().updateLayoutIgnorePendingStylesheets(); 720 document().updateLayoutIgnorePendingStylesheets();
721 if (RenderBox* rend = renderBox()) 721 if (LayoutBox* box = layoutBox())
722 return adjustLayoutUnitForAbsoluteZoom(rend->scrollHeight(), *rend).toDo uble(); 722 return adjustLayoutUnitForAbsoluteZoom(box->scrollHeight(), *box).toDoub le();
723 return 0; 723 return 0;
724 } 724 }
725 725
726 void Element::scrollBy(double x, double y) 726 void Element::scrollBy(double x, double y)
727 { 727 {
728 ScrollToOptions scrollToOptions; 728 ScrollToOptions scrollToOptions;
729 scrollToOptions.setLeft(x); 729 scrollToOptions.setLeft(x);
730 scrollToOptions.setTop(y); 730 scrollToOptions.setTop(y);
731 scrollBy(scrollToOptions); 731 scrollBy(scrollToOptions);
732 } 732 }
733 733
734 void Element::scrollBy(const ScrollToOptions& scrollToOptions) 734 void Element::scrollBy(const ScrollToOptions& scrollToOptions)
735 { 735 {
736 // FIXME: This should be removed once scroll updates are processed only afte r 736 // FIXME: This should be removed once scroll updates are processed only afte r
737 // the compositing update. See http://crbug.com/420741. 737 // the compositing update. See http://crbug.com/420741.
738 document().updateLayoutIgnorePendingStylesheets(); 738 document().updateLayoutIgnorePendingStylesheets();
739 739
740 if (document().documentElement() != this) { 740 if (document().documentElement() != this) {
741 scrollRenderBoxBy(scrollToOptions); 741 scrollLayoutBoxBy(scrollToOptions);
742 return; 742 return;
743 } 743 }
744 744
745 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 745 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
746 if (document().inQuirksMode()) 746 if (document().inQuirksMode())
747 return; 747 return;
748 scrollFrameBy(scrollToOptions); 748 scrollFrameBy(scrollToOptions);
749 } 749 }
750 } 750 }
751 751
752 void Element::scrollTo(double x, double y) 752 void Element::scrollTo(double x, double y)
753 { 753 {
754 ScrollToOptions scrollToOptions; 754 ScrollToOptions scrollToOptions;
755 scrollToOptions.setLeft(x); 755 scrollToOptions.setLeft(x);
756 scrollToOptions.setTop(y); 756 scrollToOptions.setTop(y);
757 scrollTo(scrollToOptions); 757 scrollTo(scrollToOptions);
758 } 758 }
759 759
760 void Element::scrollTo(const ScrollToOptions& scrollToOptions) 760 void Element::scrollTo(const ScrollToOptions& scrollToOptions)
761 { 761 {
762 // FIXME: This should be removed once scroll updates are processed only afte r 762 // FIXME: This should be removed once scroll updates are processed only afte r
763 // the compositing update. See http://crbug.com/420741. 763 // the compositing update. See http://crbug.com/420741.
764 document().updateLayoutIgnorePendingStylesheets(); 764 document().updateLayoutIgnorePendingStylesheets();
765 765
766 if (document().documentElement() != this) { 766 if (document().documentElement() != this) {
767 scrollRenderBoxTo(scrollToOptions); 767 scrollLayoutBoxTo(scrollToOptions);
768 return; 768 return;
769 } 769 }
770 770
771 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { 771 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
772 if (document().inQuirksMode()) 772 if (document().inQuirksMode())
773 return; 773 return;
774 scrollFrameTo(scrollToOptions); 774 scrollFrameTo(scrollToOptions);
775 } 775 }
776 } 776 }
777 777
778 void Element::scrollRenderBoxBy(const ScrollToOptions& scrollToOptions) 778 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions)
779 { 779 {
780 double left = scrollToOptions.hasLeft() ? scrollToOptions.left() : 0.0; 780 double left = scrollToOptions.hasLeft() ? scrollToOptions.left() : 0.0;
781 double top = scrollToOptions.hasTop() ? scrollToOptions.top() : 0.0; 781 double top = scrollToOptions.hasTop() ? scrollToOptions.top() : 0.0;
782 if (std::isnan(left) || std::isnan(top)) 782 if (std::isnan(left) || std::isnan(top))
783 return; 783 return;
784 784
785 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 785 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
786 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior); 786 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior);
787 RenderBox* rend = renderBox(); 787 LayoutBox* box = layoutBox();
788 if (rend) { 788 if (box) {
789 double currentScaledLeft = rend->scrollLeft(); 789 double currentScaledLeft = box->scrollLeft();
790 double currentScaledTop = rend->scrollTop(); 790 double currentScaledTop = box->scrollTop();
791 double newScaledLeft = left * rend->style()->effectiveZoom() + currentSc aledLeft; 791 double newScaledLeft = left * box->style()->effectiveZoom() + currentSca ledLeft;
792 double newScaledTop = top * rend->style()->effectiveZoom() + currentScal edTop; 792 double newScaledTop = top * box->style()->effectiveZoom() + currentScale dTop;
793 rend->scrollToOffset(DoubleSize(newScaledLeft, newScaledTop), scrollBeha vior); 793 box->scrollToOffset(DoubleSize(newScaledLeft, newScaledTop), scrollBehav ior);
794 } 794 }
795 } 795 }
796 796
797 void Element::scrollRenderBoxTo(const ScrollToOptions& scrollToOptions) 797 void Element::scrollLayoutBoxTo(const ScrollToOptions& scrollToOptions)
798 { 798 {
799 if ((scrollToOptions.hasLeft() && std::isnan(scrollToOptions.left())) 799 if ((scrollToOptions.hasLeft() && std::isnan(scrollToOptions.left()))
800 || (scrollToOptions.hasTop() && std::isnan(scrollToOptions.top()))) 800 || (scrollToOptions.hasTop() && std::isnan(scrollToOptions.top())))
801 return; 801 return;
802 802
803 ScrollBehavior scrollBehavior = ScrollBehaviorAuto; 803 ScrollBehavior scrollBehavior = ScrollBehaviorAuto;
804 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior); 804 ScrollableArea::scrollBehaviorFromString(scrollToOptions.behavior(), scrollB ehavior);
805 805
806 RenderBox* rend = renderBox(); 806 LayoutBox* box = layoutBox();
807 if (rend) { 807 if (box) {
808 double scaledLeft = rend->scrollLeft(); 808 double scaledLeft = box->scrollLeft();
809 double scaledTop = rend->scrollTop(); 809 double scaledTop = box->scrollTop();
810 if (scrollToOptions.hasLeft()) 810 if (scrollToOptions.hasLeft())
811 scaledLeft = scrollToOptions.left() * rend->style()->effectiveZoom() ; 811 scaledLeft = scrollToOptions.left() * box->style()->effectiveZoom();
812 if (scrollToOptions.hasTop()) 812 if (scrollToOptions.hasTop())
813 scaledTop = scrollToOptions.top() * rend->style()->effectiveZoom(); 813 scaledTop = scrollToOptions.top() * box->style()->effectiveZoom();
814 rend->scrollToOffset(DoubleSize(scaledLeft, scaledTop), scrollBehavior); 814 box->scrollToOffset(DoubleSize(scaledLeft, scaledTop), scrollBehavior);
815 } 815 }
816 } 816 }
817 817
818 void Element::scrollFrameBy(const ScrollToOptions& scrollToOptions) 818 void Element::scrollFrameBy(const ScrollToOptions& scrollToOptions)
819 { 819 {
820 double left = scrollToOptions.hasLeft() ? scrollToOptions.left() : 0.0; 820 double left = scrollToOptions.hasLeft() ? scrollToOptions.left() : 0.0;
821 double top = scrollToOptions.hasTop() ? scrollToOptions.top() : 0.0; 821 double top = scrollToOptions.hasTop() ? scrollToOptions.top() : 0.0;
822 if (std::isnan(left) || std::isnan(top)) 822 if (std::isnan(left) || std::isnan(top))
823 return; 823 return;
824 824
(...skipping 2556 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 { 3381 {
3382 #if ENABLE(OILPAN) 3382 #if ENABLE(OILPAN)
3383 if (hasRareData()) 3383 if (hasRareData())
3384 visitor->trace(elementRareData()); 3384 visitor->trace(elementRareData());
3385 visitor->trace(m_elementData); 3385 visitor->trace(m_elementData);
3386 #endif 3386 #endif
3387 ContainerNode::trace(visitor); 3387 ContainerNode::trace(visitor);
3388 } 3388 }
3389 3389
3390 } // namespace blink 3390 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Fullscreen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698