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

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

Issue 1660863002: Force all LayoutUnit construction to be explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix LayoutRectTest.cpp Created 4 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
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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll) 605 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati veScroll)
606 nativeApplyScroll(scrollState); 606 nativeApplyScroll(scrollState);
607 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll) 607 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte rNativeScroll)
608 callback->handleEvent(&scrollState); 608 callback->handleEvent(&scrollState);
609 }; 609 };
610 610
611 int Element::offsetLeft() 611 int Element::offsetLeft()
612 { 612 {
613 document().updateLayoutIgnorePendingStylesheets(); 613 document().updateLayoutIgnorePendingStylesheets();
614 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 614 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
615 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetL eft(), *layoutObject).round(); 615 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna ppedOffsetLeft()), layoutObject->styleRef()).round();
616 return 0; 616 return 0;
617 } 617 }
618 618
619 int Element::offsetTop() 619 int Element::offsetTop()
620 { 620 {
621 document().updateLayoutIgnorePendingStylesheets(); 621 document().updateLayoutIgnorePendingStylesheets();
622 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 622 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
623 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetT op(), *layoutObject).round(); 623 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna ppedOffsetTop()), layoutObject->styleRef()).round();
624 return 0; 624 return 0;
625 } 625 }
626 626
627 int Element::offsetWidth() 627 int Element::offsetWidth()
628 { 628 {
629 document().updateLayoutIgnorePendingStylesheets(); 629 document().updateLayoutIgnorePendingStylesheets();
630 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 630 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
631 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetW idth(), *layoutObject).round(); 631 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna ppedOffsetWidth()), layoutObject->styleRef()).round();
632 return 0; 632 return 0;
633 } 633 }
634 634
635 int Element::offsetHeight() 635 int Element::offsetHeight()
636 { 636 {
637 document().updateLayoutIgnorePendingStylesheets(); 637 document().updateLayoutIgnorePendingStylesheets();
638 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 638 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
639 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetH eight(), *layoutObject).round(); 639 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna ppedOffsetHeight()), layoutObject->styleRef()).round();
640 return 0; 640 return 0;
641 } 641 }
642 642
643 Element* Element::offsetParent() 643 Element* Element::offsetParent()
644 { 644 {
645 document().updateLayoutIgnorePendingStylesheets(); 645 document().updateLayoutIgnorePendingStylesheets();
646 646
647 LayoutObject* layoutObject = this->layoutObject(); 647 LayoutObject* layoutObject = this->layoutObject();
648 if (!layoutObject) 648 if (!layoutObject)
649 return nullptr; 649 return nullptr;
650 650
651 Element* element = layoutObject->offsetParent(); 651 Element* element = layoutObject->offsetParent();
652 if (!element) 652 if (!element)
653 return nullptr; 653 return nullptr;
654 654
655 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpenOrV 0()) 655 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpenOrV 0())
656 return nullptr; 656 return nullptr;
657 657
658 return element; 658 return element;
659 } 659 }
660 660
661 int Element::clientLeft() 661 int Element::clientLeft()
662 { 662 {
663 document().updateLayoutIgnorePendingStylesheets(); 663 document().updateLayoutIgnorePendingStylesheets();
664 664
665 if (LayoutBox* layoutObject = layoutBox()) 665 if (LayoutBox* layoutObject = layoutBox())
666 return adjustLayoutUnitForAbsoluteZoom(roundToInt(layoutObject->clientLe ft()), *layoutObject); 666 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientLeft(), layou tObject->styleRef()).round();
667 return 0; 667 return 0;
668 } 668 }
669 669
670 int Element::clientTop() 670 int Element::clientTop()
671 { 671 {
672 document().updateLayoutIgnorePendingStylesheets(); 672 document().updateLayoutIgnorePendingStylesheets();
673 673
674 if (LayoutBox* layoutObject = layoutBox()) 674 if (LayoutBox* layoutObject = layoutBox())
675 return adjustLayoutUnitForAbsoluteZoom(roundToInt(layoutObject->clientTo p()), *layoutObject); 675 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientTop(), layout Object->styleRef()).round();
676 return 0; 676 return 0;
677 } 677 }
678 678
679 int Element::clientWidth() 679 int Element::clientWidth()
680 { 680 {
681 document().updateLayoutIgnorePendingStylesheets(); 681 document().updateLayoutIgnorePendingStylesheets();
682 682
683 // When in strict mode, clientWidth for the document element should return t he width of the containing frame. 683 // When in strict mode, clientWidth for the document element should return t he width of the containing frame.
684 // When in quirks mode, clientWidth for the body element should return the w idth of the containing frame. 684 // When in quirks mode, clientWidth for the body element should return the w idth of the containing frame.
685 bool inQuirksMode = document().inQuirksMode(); 685 bool inQuirksMode = document().inQuirksMode();
686 if ((!inQuirksMode && document().documentElement() == this) 686 if ((!inQuirksMode && document().documentElement() == this)
687 || (inQuirksMode && isHTMLElement() && document().body() == this)) { 687 || (inQuirksMode && isHTMLElement() && document().body() == this)) {
688 if (LayoutView* layoutView = document().layoutView()) { 688 if (LayoutView* layoutView = document().layoutView()) {
689 if (document().page()->settings().forceZeroLayoutHeight()) 689 if (document().page()->settings().forceZeroLayoutHeight())
690 return adjustLayoutUnitForAbsoluteZoom(layoutView->overflowClipR ect(LayoutPoint()).width(), *layoutView); 690 return adjustLayoutUnitForAbsoluteZoom(layoutView->overflowClipR ect(LayoutPoint()).width(), layoutView->styleRef()).round();
691 return adjustLayoutUnitForAbsoluteZoom(layoutView->layoutSize().widt h(), *layoutView); 691 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView->layout Size().width()), layoutView->styleRef()).round();
692 } 692 }
693 } 693 }
694 694
695 if (LayoutBox* layoutObject = layoutBox()) 695 if (LayoutBox* layoutObject = layoutBox())
696 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedClientW idth(), *layoutObject).round(); 696 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna ppedClientWidth()), layoutObject->styleRef()).round();
697 return 0; 697 return 0;
698 } 698 }
699 699
700 int Element::clientHeight() 700 int Element::clientHeight()
701 { 701 {
702 document().updateLayoutIgnorePendingStylesheets(); 702 document().updateLayoutIgnorePendingStylesheets();
703 703
704 // When in strict mode, clientHeight for the document element should return the height of the containing frame. 704 // When in strict mode, clientHeight for the document element should return the height of the containing frame.
705 // When in quirks mode, clientHeight for the body element should return the height of the containing frame. 705 // When in quirks mode, clientHeight for the body element should return the height of the containing frame.
706 bool inQuirksMode = document().inQuirksMode(); 706 bool inQuirksMode = document().inQuirksMode();
707 707
708 if ((!inQuirksMode && document().documentElement() == this) 708 if ((!inQuirksMode && document().documentElement() == this)
709 || (inQuirksMode && isHTMLElement() && document().body() == this)) { 709 || (inQuirksMode && isHTMLElement() && document().body() == this)) {
710 if (LayoutView* layoutView = document().layoutView()) { 710 if (LayoutView* layoutView = document().layoutView()) {
711 if (document().page()->settings().forceZeroLayoutHeight()) 711 if (document().page()->settings().forceZeroLayoutHeight())
712 return adjustLayoutUnitForAbsoluteZoom(layoutView->overflowClipR ect(LayoutPoint()).height(), *layoutView); 712 return adjustLayoutUnitForAbsoluteZoom(layoutView->overflowClipR ect(LayoutPoint()).height(), layoutView->styleRef()).round();
713 return adjustLayoutUnitForAbsoluteZoom(layoutView->layoutSize().heig ht(), *layoutView); 713 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView->layout Size().height()), layoutView->styleRef()).round();
714 } 714 }
715 } 715 }
716 716
717 if (LayoutBox* layoutObject = layoutBox()) 717 if (LayoutBox* layoutObject = layoutBox())
718 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedClientH eight(), *layoutObject).round(); 718 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna ppedClientHeight()), layoutObject->styleRef()).round();
719 return 0; 719 return 0;
720 } 720 }
721 721
722 double Element::scrollLeft() 722 double Element::scrollLeft()
723 { 723 {
724 document().updateLayoutIgnorePendingStylesheets(); 724 document().updateLayoutIgnorePendingStylesheets();
725 725
726 if (document().scrollingElement() == this) { 726 if (document().scrollingElement() == this) {
727 if (document().domWindow()) 727 if (document().domWindow())
728 return document().domWindow()->scrollX(); 728 return document().domWindow()->scrollX();
(...skipping 2910 matching lines...) Expand 10 before | Expand all | Expand 10 after
3639 { 3639 {
3640 #if ENABLE(OILPAN) 3640 #if ENABLE(OILPAN)
3641 if (hasRareData()) 3641 if (hasRareData())
3642 visitor->trace(elementRareData()); 3642 visitor->trace(elementRareData());
3643 visitor->trace(m_elementData); 3643 visitor->trace(m_elementData);
3644 #endif 3644 #endif
3645 ContainerNode::trace(visitor); 3645 ContainerNode::trace(visitor);
3646 } 3646 }
3647 3647
3648 } // namespace blink 3648 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698