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

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

Issue 1285393003: Element should check inActiveDocument before forcing layout. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | « no previous file | no next file » | 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 return nullAtom; 437 return nullAtom;
438 } 438 }
439 439
440 bool Element::shouldIgnoreAttributeCase() const 440 bool Element::shouldIgnoreAttributeCase() const
441 { 441 {
442 return isHTMLElement() && document().isHTMLDocument(); 442 return isHTMLElement() && document().isHTMLDocument();
443 } 443 }
444 444
445 void Element::scrollIntoView(bool alignToTop) 445 void Element::scrollIntoView(bool alignToTop)
446 { 446 {
447 if (!inActiveDocument())
448 return;
449
447 document().updateLayoutIgnorePendingStylesheets(); 450 document().updateLayoutIgnorePendingStylesheets();
448 451
449 if (!layoutObject()) 452 if (!layoutObject())
450 return; 453 return;
451 454
452 LayoutRect bounds = boundingBox(); 455 LayoutRect bounds = boundingBox();
453 // Align to the top / bottom and to the closest edge. 456 // Align to the top / bottom and to the closest edge.
454 if (alignToTop) 457 if (alignToTop)
455 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignTopAlways); 458 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignTopAlways);
456 else 459 else
457 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignBottomAlways); 460 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignBottomAlways);
458 } 461 }
459 462
460 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) 463 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
461 { 464 {
465 if (!inActiveDocument())
466 return;
467
462 document().updateLayoutIgnorePendingStylesheets(); 468 document().updateLayoutIgnorePendingStylesheets();
463 469
464 if (!layoutObject()) 470 if (!layoutObject())
465 return; 471 return;
466 472
467 LayoutRect bounds = boundingBox(); 473 LayoutRect bounds = boundingBox();
468 if (centerIfNeeded) 474 if (centerIfNeeded)
469 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter IfNeeded, ScrollAlignment::alignCenterIfNeeded); 475 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter IfNeeded, ScrollAlignment::alignCenterIfNeeded);
470 else 476 else
471 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignToEdgeIfNeeded); 477 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge IfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 static double adjustForLocalZoom(LayoutUnit value, LayoutObject& layoutObject) 577 static double adjustForLocalZoom(LayoutUnit value, LayoutObject& layoutObject)
572 { 578 {
573 float zoomFactor = localZoomForLayoutObject(layoutObject); 579 float zoomFactor = localZoomForLayoutObject(layoutObject);
574 if (zoomFactor == 1) 580 if (zoomFactor == 1)
575 return value.toDouble(); 581 return value.toDouble();
576 return value.toDouble() / zoomFactor; 582 return value.toDouble() / zoomFactor;
577 } 583 }
578 584
579 int Element::offsetLeft() 585 int Element::offsetLeft()
580 { 586 {
587 if (inActiveDocument())
588 return 0;
581 document().updateLayoutIgnorePendingStylesheets(); 589 document().updateLayoutIgnorePendingStylesheets();
582 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 590 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
583 return lroundf(adjustForLocalZoom(layoutObject->offsetLeft(), *layoutObj ect)); 591 return lroundf(adjustForLocalZoom(layoutObject->offsetLeft(), *layoutObj ect));
584 return 0; 592 return 0;
585 } 593 }
586 594
587 int Element::offsetTop() 595 int Element::offsetTop()
588 { 596 {
597 if (inActiveDocument())
598 return 0;
589 document().updateLayoutIgnorePendingStylesheets(); 599 document().updateLayoutIgnorePendingStylesheets();
590 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 600 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
591 return lroundf(adjustForLocalZoom(layoutObject->pixelSnappedOffsetTop(), *layoutObject)); 601 return lroundf(adjustForLocalZoom(layoutObject->pixelSnappedOffsetTop(), *layoutObject));
592 return 0; 602 return 0;
593 } 603 }
594 604
595 int Element::offsetWidth() 605 int Element::offsetWidth()
596 { 606 {
607 if (inActiveDocument())
608 return 0;
597 document().updateLayoutIgnorePendingStylesheets(); 609 document().updateLayoutIgnorePendingStylesheets();
598 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 610 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
599 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetW idth(), *layoutObject).round(); 611 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetW idth(), *layoutObject).round();
600 return 0; 612 return 0;
601 } 613 }
602 614
603 int Element::offsetHeight() 615 int Element::offsetHeight()
604 { 616 {
617 if (inActiveDocument())
618 return 0;
605 document().updateLayoutIgnorePendingStylesheets(); 619 document().updateLayoutIgnorePendingStylesheets();
606 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) 620 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject())
607 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetH eight(), *layoutObject).round(); 621 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedOffsetH eight(), *layoutObject).round();
608 return 0; 622 return 0;
609 } 623 }
610 624
611 Element* Element::offsetParent() 625 Element* Element::offsetParent()
612 { 626 {
627 if (inActiveDocument())
628 return nullptr;
629
613 document().updateLayoutIgnorePendingStylesheets(); 630 document().updateLayoutIgnorePendingStylesheets();
614 631
615 LayoutObject* layoutObject = this->layoutObject(); 632 LayoutObject* layoutObject = this->layoutObject();
616 if (!layoutObject) 633 if (!layoutObject)
617 return nullptr; 634 return nullptr;
618 635
619 Element* element = layoutObject->offsetParent(); 636 Element* element = layoutObject->offsetParent();
620 if (!element) 637 if (!element)
621 return nullptr; 638 return nullptr;
622 639
623 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpen()) 640 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpen())
624 return nullptr; 641 return nullptr;
625 642
626 return element; 643 return element;
627 } 644 }
628 645
629 int Element::clientLeft() 646 int Element::clientLeft()
630 { 647 {
648 if (inActiveDocument())
649 return 0;
650
631 document().updateLayoutIgnorePendingStylesheets(); 651 document().updateLayoutIgnorePendingStylesheets();
632 652
633 if (LayoutBox* layoutObject = layoutBox()) 653 if (LayoutBox* layoutObject = layoutBox())
634 return adjustLayoutUnitForAbsoluteZoom(roundToInt(layoutObject->clientLe ft()), *layoutObject); 654 return adjustLayoutUnitForAbsoluteZoom(roundToInt(layoutObject->clientLe ft()), *layoutObject);
635 return 0; 655 return 0;
636 } 656 }
637 657
638 int Element::clientTop() 658 int Element::clientTop()
639 { 659 {
660 if (inActiveDocument())
661 return 0;
662
640 document().updateLayoutIgnorePendingStylesheets(); 663 document().updateLayoutIgnorePendingStylesheets();
641 664
642 if (LayoutBox* layoutObject = layoutBox()) 665 if (LayoutBox* layoutObject = layoutBox())
643 return adjustLayoutUnitForAbsoluteZoom(roundToInt(layoutObject->clientTo p()), *layoutObject); 666 return adjustLayoutUnitForAbsoluteZoom(roundToInt(layoutObject->clientTo p()), *layoutObject);
644 return 0; 667 return 0;
645 } 668 }
646 669
647 int Element::clientWidth() 670 int Element::clientWidth()
648 { 671 {
672 if (inActiveDocument())
673 return 0;
674
649 document().updateLayoutIgnorePendingStylesheets(); 675 document().updateLayoutIgnorePendingStylesheets();
650 676
651 // When in strict mode, clientWidth for the document element should return t he width of the containing frame. 677 // When in strict mode, clientWidth for the document element should return t he width of the containing frame.
652 // When in quirks mode, clientWidth for the body element should return the w idth of the containing frame. 678 // When in quirks mode, clientWidth for the body element should return the w idth of the containing frame.
653 bool inQuirksMode = document().inQuirksMode(); 679 bool inQuirksMode = document().inQuirksMode();
654 if ((!inQuirksMode && document().documentElement() == this) 680 if ((!inQuirksMode && document().documentElement() == this)
655 || (inQuirksMode && isHTMLElement() && document().body() == this)) { 681 || (inQuirksMode && isHTMLElement() && document().body() == this)) {
656 if (FrameView* view = document().view()) { 682 if (FrameView* view = document().view()) {
657 if (LayoutView* layoutView = document().layoutView()) { 683 if (LayoutView* layoutView = document().layoutView()) {
658 if (document().page()->settings().forceZeroLayoutHeight()) 684 if (document().page()->settings().forceZeroLayoutHeight())
659 return adjustLayoutUnitForAbsoluteZoom(view->visibleContentS ize().width(), *layoutView); 685 return adjustLayoutUnitForAbsoluteZoom(view->visibleContentS ize().width(), *layoutView);
660 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width( ), *layoutView); 686 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width( ), *layoutView);
661 } 687 }
662 } 688 }
663 } 689 }
664 690
665 if (LayoutBox* layoutObject = layoutBox()) 691 if (LayoutBox* layoutObject = layoutBox())
666 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedClientW idth(), *layoutObject).round(); 692 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedClientW idth(), *layoutObject).round();
667 return 0; 693 return 0;
668 } 694 }
669 695
670 int Element::clientHeight() 696 int Element::clientHeight()
671 { 697 {
698 if (inActiveDocument())
699 return 0;
700
672 document().updateLayoutIgnorePendingStylesheets(); 701 document().updateLayoutIgnorePendingStylesheets();
673 702
674 // When in strict mode, clientHeight for the document element should return the height of the containing frame. 703 // When in strict mode, clientHeight for the document element should return the height of the containing frame.
675 // When in quirks mode, clientHeight for the body element should return the height of the containing frame. 704 // When in quirks mode, clientHeight for the body element should return the height of the containing frame.
676 bool inQuirksMode = document().inQuirksMode(); 705 bool inQuirksMode = document().inQuirksMode();
677 706
678 if ((!inQuirksMode && document().documentElement() == this) 707 if ((!inQuirksMode && document().documentElement() == this)
679 || (inQuirksMode && isHTMLElement() && document().body() == this)) { 708 || (inQuirksMode && isHTMLElement() && document().body() == this)) {
680 if (FrameView* view = document().view()) { 709 if (FrameView* view = document().view()) {
681 if (LayoutView* layoutView = document().layoutView()) { 710 if (LayoutView* layoutView = document().layoutView()) {
682 if (document().page()->settings().forceZeroLayoutHeight()) 711 if (document().page()->settings().forceZeroLayoutHeight())
683 return adjustLayoutUnitForAbsoluteZoom(view->visibleContentS ize().height(), *layoutView); 712 return adjustLayoutUnitForAbsoluteZoom(view->visibleContentS ize().height(), *layoutView);
684 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height (), *layoutView); 713 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height (), *layoutView);
685 } 714 }
686 } 715 }
687 } 716 }
688 717
689 if (LayoutBox* layoutObject = layoutBox()) 718 if (LayoutBox* layoutObject = layoutBox())
690 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedClientH eight(), *layoutObject).round(); 719 return adjustLayoutUnitForAbsoluteZoom(layoutObject->pixelSnappedClientH eight(), *layoutObject).round();
691 return 0; 720 return 0;
692 } 721 }
693 722
694 double Element::scrollLeft() 723 double Element::scrollLeft()
695 { 724 {
725 if (inActiveDocument())
726 return 0;
727
696 document().updateLayoutIgnorePendingStylesheets(); 728 document().updateLayoutIgnorePendingStylesheets();
697 729
698 if (document().scrollingElement() == this) { 730 if (document().scrollingElement() == this) {
699 if (document().domWindow()) 731 if (document().domWindow())
700 return document().domWindow()->scrollX(); 732 return document().domWindow()->scrollX();
701 return 0; 733 return 0;
702 } 734 }
703 735
704 if (LayoutBox* box = layoutBox()) 736 if (LayoutBox* box = layoutBox())
705 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); 737 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box);
706 738
707 return 0; 739 return 0;
708 } 740 }
709 741
710 double Element::scrollTop() 742 double Element::scrollTop()
711 { 743 {
744 if (inActiveDocument())
745 return 0;
746
712 document().updateLayoutIgnorePendingStylesheets(); 747 document().updateLayoutIgnorePendingStylesheets();
713 748
714 if (document().scrollingElement() == this) { 749 if (document().scrollingElement() == this) {
715 if (document().domWindow()) 750 if (document().domWindow())
716 return document().domWindow()->scrollY(); 751 return document().domWindow()->scrollY();
717 return 0; 752 return 0;
718 } 753 }
719 754
720 if (LayoutBox* box = layoutBox()) 755 if (LayoutBox* box = layoutBox())
721 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); 756 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box);
722 757
723 return 0; 758 return 0;
724 } 759 }
725 760
726 void Element::setScrollLeft(double newLeft) 761 void Element::setScrollLeft(double newLeft)
727 { 762 {
763 if (!inActiveDocument())
764 return;
765
728 document().updateLayoutIgnorePendingStylesheets(); 766 document().updateLayoutIgnorePendingStylesheets();
729 767
730 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); 768 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft);
731 769
732 if (document().scrollingElement() == this) { 770 if (document().scrollingElement() == this) {
733 if (LocalDOMWindow* window = document().domWindow()) 771 if (LocalDOMWindow* window = document().domWindow())
734 window->scrollTo(newLeft, window->scrollY()); 772 window->scrollTo(newLeft, window->scrollY());
735 } else { 773 } else {
736 LayoutBox* box = layoutBox(); 774 LayoutBox* box = layoutBox();
737 if (box) 775 if (box)
738 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style() ->effectiveZoom())); 776 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style() ->effectiveZoom()));
739 } 777 }
740 } 778 }
741 779
742 void Element::setScrollTop(double newTop) 780 void Element::setScrollTop(double newTop)
743 { 781 {
782 if (!inActiveDocument())
783 return;
784
744 document().updateLayoutIgnorePendingStylesheets(); 785 document().updateLayoutIgnorePendingStylesheets();
745 786
746 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); 787 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop);
747 788
748 if (document().scrollingElement() == this) { 789 if (document().scrollingElement() == this) {
749 if (LocalDOMWindow* window = document().domWindow()) 790 if (LocalDOMWindow* window = document().domWindow())
750 window->scrollTo(window->scrollX(), newTop); 791 window->scrollTo(window->scrollX(), newTop);
751 } else { 792 } else {
752 LayoutBox* box = layoutBox(); 793 LayoutBox* box = layoutBox();
753 if (box) 794 if (box)
754 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()-> effectiveZoom())); 795 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()-> effectiveZoom()));
755 } 796 }
756 } 797 }
757 798
758 int Element::scrollWidth() 799 int Element::scrollWidth()
759 { 800 {
801 if (!inActiveDocument())
802 return 0;
803
760 document().updateLayoutIgnorePendingStylesheets(); 804 document().updateLayoutIgnorePendingStylesheets();
761 805
762 if (document().scrollingElement() == this) { 806 if (document().scrollingElement() == this) {
763 if (document().view()) 807 if (document().view())
764 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc ument().frame()->pageZoomFactor()); 808 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc ument().frame()->pageZoomFactor());
765 return 0; 809 return 0;
766 } 810 }
767 811
768 if (LayoutBox* box = layoutBox()) 812 if (LayoutBox* box = layoutBox())
769 return adjustLayoutUnitForAbsoluteZoom(box->scrollWidth(), *box).round() ; 813 return adjustLayoutUnitForAbsoluteZoom(box->scrollWidth(), *box).round() ;
770 return 0; 814 return 0;
771 } 815 }
772 816
773 int Element::scrollHeight() 817 int Element::scrollHeight()
774 { 818 {
819 if (!inActiveDocument())
820 return 0;
821
775 document().updateLayoutIgnorePendingStylesheets(); 822 document().updateLayoutIgnorePendingStylesheets();
776 823
777 if (document().scrollingElement() == this) { 824 if (document().scrollingElement() == this) {
778 if (document().view()) 825 if (document().view())
779 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do cument().frame()->pageZoomFactor()); 826 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do cument().frame()->pageZoomFactor());
780 return 0; 827 return 0;
781 } 828 }
782 829
783 if (LayoutBox* box = layoutBox()) 830 if (LayoutBox* box = layoutBox())
784 return adjustLayoutUnitForAbsoluteZoom(box->scrollHeight(), *box).round( ); 831 return adjustLayoutUnitForAbsoluteZoom(box->scrollHeight(), *box).round( );
785 return 0; 832 return 0;
786 } 833 }
787 834
788 void Element::scrollBy(double x, double y) 835 void Element::scrollBy(double x, double y)
789 { 836 {
790 ScrollToOptions scrollToOptions; 837 ScrollToOptions scrollToOptions;
791 scrollToOptions.setLeft(x); 838 scrollToOptions.setLeft(x);
792 scrollToOptions.setTop(y); 839 scrollToOptions.setTop(y);
793 scrollBy(scrollToOptions); 840 scrollBy(scrollToOptions);
794 } 841 }
795 842
796 void Element::scrollBy(const ScrollToOptions& scrollToOptions) 843 void Element::scrollBy(const ScrollToOptions& scrollToOptions)
797 { 844 {
845 if (!inActiveDocument())
846 return;
847
798 // FIXME: This should be removed once scroll updates are processed only afte r 848 // FIXME: This should be removed once scroll updates are processed only afte r
799 // the compositing update. See http://crbug.com/420741. 849 // the compositing update. See http://crbug.com/420741.
800 document().updateLayoutIgnorePendingStylesheets(); 850 document().updateLayoutIgnorePendingStylesheets();
801 851
802 if (document().scrollingElement() == this) { 852 if (document().scrollingElement() == this) {
803 scrollFrameBy(scrollToOptions); 853 scrollFrameBy(scrollToOptions);
804 } else { 854 } else {
805 scrollLayoutBoxBy(scrollToOptions); 855 scrollLayoutBoxBy(scrollToOptions);
806 } 856 }
807 } 857 }
808 858
809 void Element::scrollTo(double x, double y) 859 void Element::scrollTo(double x, double y)
810 { 860 {
811 ScrollToOptions scrollToOptions; 861 ScrollToOptions scrollToOptions;
812 scrollToOptions.setLeft(x); 862 scrollToOptions.setLeft(x);
813 scrollToOptions.setTop(y); 863 scrollToOptions.setTop(y);
814 scrollTo(scrollToOptions); 864 scrollTo(scrollToOptions);
815 } 865 }
816 866
817 void Element::scrollTo(const ScrollToOptions& scrollToOptions) 867 void Element::scrollTo(const ScrollToOptions& scrollToOptions)
818 { 868 {
869 if (!inActiveDocument())
870 return;
871
819 // FIXME: This should be removed once scroll updates are processed only afte r 872 // FIXME: This should be removed once scroll updates are processed only afte r
820 // the compositing update. See http://crbug.com/420741. 873 // the compositing update. See http://crbug.com/420741.
821 document().updateLayoutIgnorePendingStylesheets(); 874 document().updateLayoutIgnorePendingStylesheets();
822 875
823 if (document().scrollingElement() == this) { 876 if (document().scrollingElement() == this) {
824 scrollFrameTo(scrollToOptions); 877 scrollFrameTo(scrollToOptions);
825 } else { 878 } else {
826 scrollLayoutBoxTo(scrollToOptions); 879 scrollLayoutBoxTo(scrollToOptions);
827 } 880 }
828 } 881 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 960 }
908 961
909 void Element::decrementProxyCount() 962 void Element::decrementProxyCount()
910 { 963 {
911 if (ensureElementRareData().decrementProxyCount() == 0) 964 if (ensureElementRareData().decrementProxyCount() == 0)
912 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat e(StyleChangeReason::CompositorProxy)); 965 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat e(StyleChangeReason::CompositorProxy));
913 } 966 }
914 967
915 bool Element::hasNonEmptyLayoutSize() const 968 bool Element::hasNonEmptyLayoutSize() const
916 { 969 {
970 if (!inActiveDocument())
971 return false;
972
917 document().updateLayoutIgnorePendingStylesheets(); 973 document().updateLayoutIgnorePendingStylesheets();
918 974
919 if (LayoutBoxModelObject* box = layoutBoxModelObject()) 975 if (LayoutBoxModelObject* box = layoutBoxModelObject())
920 return box->hasNonEmptyLayoutSize(); 976 return box->hasNonEmptyLayoutSize();
921 return false; 977 return false;
922 } 978 }
923 979
924 IntRect Element::boundsInViewportSpace() 980 IntRect Element::boundsInViewportSpace()
925 { 981 {
982 if (!inActiveDocument())
983 return IntRect();
984
926 document().updateLayoutIgnorePendingStylesheets(); 985 document().updateLayoutIgnorePendingStylesheets();
927 986
928 FrameView* view = document().view(); 987 FrameView* view = document().view();
929 if (!view) 988 if (!view)
930 return IntRect(); 989 return IntRect();
931 990
932 Vector<FloatQuad> quads; 991 Vector<FloatQuad> quads;
933 if (isSVGElement() && layoutObject()) { 992 if (isSVGElement() && layoutObject()) {
934 // Get the bounding rectangle from the SVG model. 993 // Get the bounding rectangle from the SVG model.
935 SVGElement* svgElement = toSVGElement(this); 994 SVGElement* svgElement = toSVGElement(this);
(...skipping 11 matching lines...) Expand all
947 1006
948 IntRect result = quads[0].enclosingBoundingBox(); 1007 IntRect result = quads[0].enclosingBoundingBox();
949 for (size_t i = 1; i < quads.size(); ++i) 1008 for (size_t i = 1; i < quads.size(); ++i)
950 result.unite(quads[i].enclosingBoundingBox()); 1009 result.unite(quads[i].enclosingBoundingBox());
951 1010
952 return view->soonToBeRemovedContentsToUnscaledViewport(result); 1011 return view->soonToBeRemovedContentsToUnscaledViewport(result);
953 } 1012 }
954 1013
955 ClientRectList* Element::getClientRects() 1014 ClientRectList* Element::getClientRects()
956 { 1015 {
1016 if (!inActiveDocument())
1017 return ClientRectList::create();
1018
957 document().updateLayoutIgnorePendingStylesheets(); 1019 document().updateLayoutIgnorePendingStylesheets();
958 1020
959 LayoutObject* elementLayoutObject = layoutObject(); 1021 LayoutObject* elementLayoutObject = layoutObject();
960 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el ementLayoutObject->isBR())) 1022 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el ementLayoutObject->isBR()))
961 return ClientRectList::create(); 1023 return ClientRectList::create();
962 1024
963 // FIXME: Handle SVG elements. 1025 // FIXME: Handle SVG elements.
964 // FIXME: Handle table/inline-table with a caption. 1026 // FIXME: Handle table/inline-table with a caption.
965 1027
966 Vector<FloatQuad> quads; 1028 Vector<FloatQuad> quads;
967 elementLayoutObject->absoluteQuads(quads); 1029 elementLayoutObject->absoluteQuads(quads);
968 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj ect); 1030 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj ect);
969 return ClientRectList::create(quads); 1031 return ClientRectList::create(quads);
970 } 1032 }
971 1033
972 ClientRect* Element::getBoundingClientRect() 1034 ClientRect* Element::getBoundingClientRect()
973 { 1035 {
1036 if (!inActiveDocument())
1037 return ClientRect::create();
1038
974 document().updateLayoutIgnorePendingStylesheets(); 1039 document().updateLayoutIgnorePendingStylesheets();
975 1040
976 Vector<FloatQuad> quads; 1041 Vector<FloatQuad> quads;
977 LayoutObject* elementLayoutObject = layoutObject(); 1042 LayoutObject* elementLayoutObject = layoutObject();
978 if (elementLayoutObject) { 1043 if (elementLayoutObject) {
979 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { 1044 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) {
980 // Get the bounding rectangle from the SVG model. 1045 // Get the bounding rectangle from the SVG model.
981 SVGElement* svgElement = toSVGElement(this); 1046 SVGElement* svgElement = toSVGElement(this);
982 FloatRect localRect; 1047 FloatRect localRect;
983 if (svgElement->getBoundingBox(localRect)) 1048 if (svgElement->getBoundingBox(localRect))
(...skipping 18 matching lines...) Expand all
1002 IntRect Element::screenRect() const 1067 IntRect Element::screenRect() const
1003 { 1068 {
1004 if (!layoutObject()) 1069 if (!layoutObject())
1005 return IntRect(); 1070 return IntRect();
1006 // FIXME: this should probably respect transforms 1071 // FIXME: this should probably respect transforms
1007 return document().view()->contentsToScreen(layoutObject()->absoluteBoundingB oxRectIgnoringTransforms()); 1072 return document().view()->contentsToScreen(layoutObject()->absoluteBoundingB oxRectIgnoringTransforms());
1008 } 1073 }
1009 1074
1010 const AtomicString& Element::computedRole() 1075 const AtomicString& Element::computedRole()
1011 { 1076 {
1012 document().updateLayoutIgnorePendingStylesheets(); 1077 if (inActiveDocument())
1078 document().updateLayoutIgnorePendingStylesheets();
1013 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); 1079 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document());
1014 return cache->get()->computedRoleForNode(this); 1080 return cache->get()->computedRoleForNode(this);
1015 } 1081 }
1016 1082
1017 String Element::computedName() 1083 String Element::computedName()
1018 { 1084 {
1019 document().updateLayoutIgnorePendingStylesheets(); 1085 if (inActiveDocument())
1086 document().updateLayoutIgnorePendingStylesheets();
1020 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); 1087 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document());
1021 return cache->get()->computedNameForNode(this); 1088 return cache->get()->computedNameForNode(this);
1022 } 1089 }
1023 1090
1024 const AtomicString& Element::getAttribute(const AtomicString& localName) const 1091 const AtomicString& Element::getAttribute(const AtomicString& localName) const
1025 { 1092 {
1026 if (!elementData()) 1093 if (!elementData())
1027 return nullAtom; 1094 return nullAtom;
1028 synchronizeAttribute(localName); 1095 synchronizeAttribute(localName);
1029 if (const Attribute* attribute = elementData()->attributes().find(localName, shouldIgnoreAttributeCase())) 1096 if (const Attribute* attribute = elementData()->attributes().find(localName, shouldIgnoreAttributeCase()))
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 { 2330 {
2264 if (!elementData()) 2331 if (!elementData())
2265 return false; 2332 return false;
2266 QualifiedName qName(nullAtom, localName, namespaceURI); 2333 QualifiedName qName(nullAtom, localName, namespaceURI);
2267 synchronizeAttribute(qName); 2334 synchronizeAttribute(qName);
2268 return elementData()->attributes().find(qName); 2335 return elementData()->attributes().find(qName);
2269 } 2336 }
2270 2337
2271 void Element::focus(bool restorePreviousSelection, WebFocusType type, InputDevic eCapabilities* sourceCapabilities) 2338 void Element::focus(bool restorePreviousSelection, WebFocusType type, InputDevic eCapabilities* sourceCapabilities)
2272 { 2339 {
2273 if (!inDocument()) 2340 if (!inActiveDocument())
2274 return; 2341 return;
2275 2342
2276 if (document().focusedElement() == this) 2343 if (document().focusedElement() == this)
2277 return; 2344 return;
2278 2345
2279 if (!document().isActive())
2280 return;
2281
2282 document().updateLayoutIgnorePendingStylesheets(); 2346 document().updateLayoutIgnorePendingStylesheets();
2283 if (!isFocusable()) 2347 if (!isFocusable())
2284 return; 2348 return;
2285 2349
2286 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { 2350 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) {
2287 if (containsIncludingShadowDOM(document().focusedElement())) 2351 if (containsIncludingShadowDOM(document().focusedElement()))
2288 return; 2352 return;
2289 2353
2290 // Slide the focus to its inner node. 2354 // Slide the focus to its inner node.
2291 Element* next = document().page()->focusController().findFocusableElemen t(WebFocusTypeForward, *this); 2355 Element* next = document().page()->focusController().findFocusableElemen t(WebFocusTypeForward, *this);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 2614
2551 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH TML(markup, contextElement.get(), AllowScriptingContent, "insertAdjacentHTML", e xceptionState); 2615 RefPtrWillBeRawPtr<DocumentFragment> fragment = createFragmentForInnerOuterH TML(markup, contextElement.get(), AllowScriptingContent, "insertAdjacentHTML", e xceptionState);
2552 if (!fragment) 2616 if (!fragment)
2553 return; 2617 return;
2554 insertAdjacent(where, fragment.get(), exceptionState); 2618 insertAdjacent(where, fragment.get(), exceptionState);
2555 } 2619 }
2556 2620
2557 String Element::innerText() 2621 String Element::innerText()
2558 { 2622 {
2559 // We need to update layout, since plainText uses line boxes in the layout t ree. 2623 // We need to update layout, since plainText uses line boxes in the layout t ree.
2560 document().updateLayoutIgnorePendingStylesheets(); 2624 if (inActiveDocument())
2625 document().updateLayoutIgnorePendingStylesheets();
2561 2626
2562 if (!layoutObject()) 2627 if (!layoutObject())
2563 return textContent(true); 2628 return textContent(true);
2564 2629
2565 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne rText); 2630 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne rText);
2566 } 2631 }
2567 2632
2568 String Element::outerText() 2633 String Element::outerText()
2569 { 2634 {
2570 // Getting outerText is the same as getting innerText, only 2635 // Getting outerText is the same as getting innerText, only
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 { 3563 {
3499 #if ENABLE(OILPAN) 3564 #if ENABLE(OILPAN)
3500 if (hasRareData()) 3565 if (hasRareData())
3501 visitor->trace(elementRareData()); 3566 visitor->trace(elementRareData());
3502 visitor->trace(m_elementData); 3567 visitor->trace(m_elementData);
3503 #endif 3568 #endif
3504 ContainerNode::trace(visitor); 3569 ContainerNode::trace(visitor);
3505 } 3570 }
3506 3571
3507 } // namespace blink 3572 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698