OLD | NEW |
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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 return nullAtom; | 453 return nullAtom; |
454 } | 454 } |
455 | 455 |
456 bool Element::shouldIgnoreAttributeCase() const | 456 bool Element::shouldIgnoreAttributeCase() const |
457 { | 457 { |
458 return isHTMLElement() && document().isHTMLDocument(); | 458 return isHTMLElement() && document().isHTMLDocument(); |
459 } | 459 } |
460 | 460 |
461 void Element::scrollIntoView(bool alignToTop) | 461 void Element::scrollIntoView(bool alignToTop) |
462 { | 462 { |
463 document().updateLayoutIgnorePendingStylesheets(); | 463 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
464 | 464 |
465 if (!layoutObject()) | 465 if (!layoutObject()) |
466 return; | 466 return; |
467 | 467 |
468 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); | 468 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); |
469 | 469 |
470 LayoutRect bounds = boundingBox(); | 470 LayoutRect bounds = boundingBox(); |
471 // Align to the top / bottom and to the closest edge. | 471 // Align to the top / bottom and to the closest edge. |
472 if (alignToTop) | 472 if (alignToTop) |
473 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignTopAlways, ProgrammaticScroll, makeVisibleInVisu
alViewport); | 473 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignTopAlways, ProgrammaticScroll, makeVisibleInVisu
alViewport); |
474 else | 474 else |
475 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignBottomAlways, ProgrammaticScroll, makeVisibleInV
isualViewport); | 475 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignBottomAlways, ProgrammaticScroll, makeVisibleInV
isualViewport); |
476 | 476 |
477 document().setSequentialFocusNavigationStartingPoint(this); | 477 document().setSequentialFocusNavigationStartingPoint(this); |
478 } | 478 } |
479 | 479 |
480 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) | 480 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) |
481 { | 481 { |
482 document().updateLayoutIgnorePendingStylesheets(); | 482 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
483 | 483 |
484 if (!layoutObject()) | 484 if (!layoutObject()) |
485 return; | 485 return; |
486 | 486 |
487 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); | 487 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); |
488 | 488 |
489 LayoutRect bounds = boundingBox(); | 489 LayoutRect bounds = boundingBox(); |
490 if (centerIfNeeded) | 490 if (centerIfNeeded) |
491 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded, ProgrammaticScroll, makeVisibleI
nVisualViewport); | 491 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded, ProgrammaticScroll, makeVisibleI
nVisualViewport); |
492 else | 492 else |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 void Element::nativeApplyScroll(ScrollState& scrollState) | 549 void Element::nativeApplyScroll(ScrollState& scrollState) |
550 { | 550 { |
551 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); | 551 ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); |
552 if (scrollState.fullyConsumed()) | 552 if (scrollState.fullyConsumed()) |
553 return; | 553 return; |
554 | 554 |
555 const double deltaX = scrollState.deltaX(); | 555 const double deltaX = scrollState.deltaX(); |
556 const double deltaY = scrollState.deltaY(); | 556 const double deltaY = scrollState.deltaY(); |
557 bool scrolled = false; | 557 bool scrolled = false; |
558 | 558 |
| 559 // TODO(esprehn): This should use updateLayoutIgnorePendingStylesheetsForNod
e. |
559 if (deltaY || deltaX) | 560 if (deltaY || deltaX) |
560 document().updateLayoutIgnorePendingStylesheets(); | 561 document().updateLayoutIgnorePendingStylesheets(); |
561 | 562 |
562 // Handle the scrollingElement separately, as it scrolls the viewport. | 563 // Handle the scrollingElement separately, as it scrolls the viewport. |
563 if (this == document().scrollingElement()) { | 564 if (this == document().scrollingElement()) { |
564 FloatSize delta(deltaX, deltaY); | 565 FloatSize delta(deltaX, deltaY); |
565 if (document().frame()->applyScrollDelta(ScrollByPrecisePixel, delta, sc
rollState.isBeginning()).didScroll()) { | 566 if (document().frame()->applyScrollDelta(ScrollByPrecisePixel, delta, sc
rollState.isBeginning()).didScroll()) { |
566 scrolled = true; | 567 scrolled = true; |
567 scrollState.consumeDeltaNative(scrollState.deltaX(), scrollState.del
taY()); | 568 scrollState.consumeDeltaNative(scrollState.deltaX(), scrollState.del
taY()); |
568 } | 569 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte
rNativeScroll) | 608 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte
rNativeScroll) |
608 callback->handleEvent(&scrollState); | 609 callback->handleEvent(&scrollState); |
609 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati
veScroll) | 610 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati
veScroll) |
610 nativeApplyScroll(scrollState); | 611 nativeApplyScroll(scrollState); |
611 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte
rNativeScroll) | 612 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte
rNativeScroll) |
612 callback->handleEvent(&scrollState); | 613 callback->handleEvent(&scrollState); |
613 }; | 614 }; |
614 | 615 |
615 int Element::offsetLeft() | 616 int Element::offsetLeft() |
616 { | 617 { |
617 document().updateLayoutIgnorePendingStylesheets(); | 618 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
618 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 619 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
619 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetLeft()), layoutObject->styleRef()).round(); | 620 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetLeft()), layoutObject->styleRef()).round(); |
620 return 0; | 621 return 0; |
621 } | 622 } |
622 | 623 |
623 int Element::offsetTop() | 624 int Element::offsetTop() |
624 { | 625 { |
625 document().updateLayoutIgnorePendingStylesheets(); | 626 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
626 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 627 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
627 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetTop()), layoutObject->styleRef()).round(); | 628 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetTop()), layoutObject->styleRef()).round(); |
628 return 0; | 629 return 0; |
629 } | 630 } |
630 | 631 |
631 int Element::offsetWidth() | 632 int Element::offsetWidth() |
632 { | 633 { |
633 document().updateLayoutIgnorePendingStylesheets(); | 634 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
634 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 635 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
635 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetWidth()), layoutObject->styleRef()).round(); | 636 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetWidth()), layoutObject->styleRef()).round(); |
636 return 0; | 637 return 0; |
637 } | 638 } |
638 | 639 |
639 int Element::offsetHeight() | 640 int Element::offsetHeight() |
640 { | 641 { |
641 document().updateLayoutIgnorePendingStylesheets(); | 642 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
642 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 643 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
643 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetHeight()), layoutObject->styleRef()).round(); | 644 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetHeight()), layoutObject->styleRef()).round(); |
644 return 0; | 645 return 0; |
645 } | 646 } |
646 | 647 |
647 Element* Element::offsetParent() | 648 Element* Element::offsetParent() |
648 { | 649 { |
649 document().updateLayoutIgnorePendingStylesheets(); | 650 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
650 | 651 |
651 LayoutObject* layoutObject = this->layoutObject(); | 652 LayoutObject* layoutObject = this->layoutObject(); |
652 if (!layoutObject) | 653 if (!layoutObject) |
653 return nullptr; | 654 return nullptr; |
654 | 655 |
655 Element* element = layoutObject->offsetParent(); | 656 Element* element = layoutObject->offsetParent(); |
656 if (!element) | 657 if (!element) |
657 return nullptr; | 658 return nullptr; |
658 | 659 |
659 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpenOrV
0()) | 660 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpenOrV
0()) |
660 return nullptr; | 661 return nullptr; |
661 | 662 |
662 return element; | 663 return element; |
663 } | 664 } |
664 | 665 |
665 int Element::clientLeft() | 666 int Element::clientLeft() |
666 { | 667 { |
667 document().updateLayoutIgnorePendingStylesheets(); | 668 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
668 | 669 |
669 if (LayoutBox* layoutObject = layoutBox()) | 670 if (LayoutBox* layoutObject = layoutBox()) |
670 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientLeft(), layou
tObject->styleRef()).round(); | 671 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientLeft(), layou
tObject->styleRef()).round(); |
671 return 0; | 672 return 0; |
672 } | 673 } |
673 | 674 |
674 int Element::clientTop() | 675 int Element::clientTop() |
675 { | 676 { |
676 document().updateLayoutIgnorePendingStylesheets(); | 677 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
677 | 678 |
678 if (LayoutBox* layoutObject = layoutBox()) | 679 if (LayoutBox* layoutObject = layoutBox()) |
679 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientTop(), layout
Object->styleRef()).round(); | 680 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientTop(), layout
Object->styleRef()).round(); |
680 return 0; | 681 return 0; |
681 } | 682 } |
682 | 683 |
683 int Element::clientWidth() | 684 int Element::clientWidth() |
684 { | 685 { |
685 document().updateLayoutIgnorePendingStylesheets(); | 686 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
686 | 687 |
687 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. | 688 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. |
688 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. | 689 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. |
689 bool inQuirksMode = document().inQuirksMode(); | 690 bool inQuirksMode = document().inQuirksMode(); |
690 if ((!inQuirksMode && document().documentElement() == this) | 691 if ((!inQuirksMode && document().documentElement() == this) |
691 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 692 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
692 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ | 693 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ |
693 if (document().page()->settings().forceZeroLayoutHeight()) | 694 if (document().page()->settings().forceZeroLayoutHeight()) |
694 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).width(), layoutView.styleRef()).round(); | 695 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).width(), layoutView.styleRef()).round(); |
695 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().width()), layoutView.styleRef()).round(); | 696 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().width()), layoutView.styleRef()).round(); |
696 } | 697 } |
697 } | 698 } |
698 | 699 |
699 if (LayoutBox* layoutObject = layoutBox()) | 700 if (LayoutBox* layoutObject = layoutBox()) |
700 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientWidth()), layoutObject->styleRef()).round(); | 701 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientWidth()), layoutObject->styleRef()).round(); |
701 return 0; | 702 return 0; |
702 } | 703 } |
703 | 704 |
704 int Element::clientHeight() | 705 int Element::clientHeight() |
705 { | 706 { |
706 document().updateLayoutIgnorePendingStylesheets(); | 707 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
707 | 708 |
708 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. | 709 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. |
709 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. | 710 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. |
710 bool inQuirksMode = document().inQuirksMode(); | 711 bool inQuirksMode = document().inQuirksMode(); |
711 | 712 |
712 if ((!inQuirksMode && document().documentElement() == this) | 713 if ((!inQuirksMode && document().documentElement() == this) |
713 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 714 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
714 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ | 715 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ |
715 if (document().page()->settings().forceZeroLayoutHeight()) | 716 if (document().page()->settings().forceZeroLayoutHeight()) |
716 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).height(), layoutView.styleRef()).round(); | 717 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).height(), layoutView.styleRef()).round(); |
717 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().height()), layoutView.styleRef()).round(); | 718 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().height()), layoutView.styleRef()).round(); |
718 } | 719 } |
719 } | 720 } |
720 | 721 |
721 if (LayoutBox* layoutObject = layoutBox()) | 722 if (LayoutBox* layoutObject = layoutBox()) |
722 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientHeight()), layoutObject->styleRef()).round(); | 723 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientHeight()), layoutObject->styleRef()).round(); |
723 return 0; | 724 return 0; |
724 } | 725 } |
725 | 726 |
726 double Element::scrollLeft() | 727 double Element::scrollLeft() |
727 { | 728 { |
728 document().updateLayoutIgnorePendingStylesheets(); | 729 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
729 | 730 |
730 if (document().scrollingElement() == this) { | 731 if (document().scrollingElement() == this) { |
731 if (document().domWindow()) | 732 if (document().domWindow()) |
732 return document().domWindow()->scrollX(); | 733 return document().domWindow()->scrollX(); |
733 return 0; | 734 return 0; |
734 } | 735 } |
735 | 736 |
736 if (LayoutBox* box = layoutBox()) | 737 if (LayoutBox* box = layoutBox()) |
737 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); | 738 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); |
738 | 739 |
739 return 0; | 740 return 0; |
740 } | 741 } |
741 | 742 |
742 double Element::scrollTop() | 743 double Element::scrollTop() |
743 { | 744 { |
744 document().updateLayoutIgnorePendingStylesheets(); | 745 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
745 | 746 |
746 if (document().scrollingElement() == this) { | 747 if (document().scrollingElement() == this) { |
747 if (document().domWindow()) | 748 if (document().domWindow()) |
748 return document().domWindow()->scrollY(); | 749 return document().domWindow()->scrollY(); |
749 return 0; | 750 return 0; |
750 } | 751 } |
751 | 752 |
752 if (LayoutBox* box = layoutBox()) | 753 if (LayoutBox* box = layoutBox()) |
753 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); | 754 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); |
754 | 755 |
755 return 0; | 756 return 0; |
756 } | 757 } |
757 | 758 |
758 void Element::setScrollLeft(double newLeft) | 759 void Element::setScrollLeft(double newLeft) |
759 { | 760 { |
760 document().updateLayoutIgnorePendingStylesheets(); | 761 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
761 | 762 |
762 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); | 763 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); |
763 | 764 |
764 if (document().scrollingElement() == this) { | 765 if (document().scrollingElement() == this) { |
765 if (LocalDOMWindow* window = document().domWindow()) | 766 if (LocalDOMWindow* window = document().domWindow()) |
766 window->scrollTo(newLeft, window->scrollY()); | 767 window->scrollTo(newLeft, window->scrollY()); |
767 } else { | 768 } else { |
768 LayoutBox* box = layoutBox(); | 769 LayoutBox* box = layoutBox(); |
769 if (box) | 770 if (box) |
770 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()
->effectiveZoom())); | 771 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()
->effectiveZoom())); |
771 } | 772 } |
772 } | 773 } |
773 | 774 |
774 void Element::setScrollTop(double newTop) | 775 void Element::setScrollTop(double newTop) |
775 { | 776 { |
776 document().updateLayoutIgnorePendingStylesheets(); | 777 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
777 | 778 |
778 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); | 779 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); |
779 | 780 |
780 if (document().scrollingElement() == this) { | 781 if (document().scrollingElement() == this) { |
781 if (LocalDOMWindow* window = document().domWindow()) | 782 if (LocalDOMWindow* window = document().domWindow()) |
782 window->scrollTo(window->scrollX(), newTop); | 783 window->scrollTo(window->scrollX(), newTop); |
783 } else { | 784 } else { |
784 LayoutBox* box = layoutBox(); | 785 LayoutBox* box = layoutBox(); |
785 if (box) | 786 if (box) |
786 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->
effectiveZoom())); | 787 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->
effectiveZoom())); |
787 } | 788 } |
788 } | 789 } |
789 | 790 |
790 int Element::scrollWidth() | 791 int Element::scrollWidth() |
791 { | 792 { |
792 document().updateLayoutIgnorePendingStylesheets(); | 793 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
793 | 794 |
794 if (document().scrollingElement() == this) { | 795 if (document().scrollingElement() == this) { |
795 if (document().view()) | 796 if (document().view()) |
796 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc
ument().frame()->pageZoomFactor()); | 797 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc
ument().frame()->pageZoomFactor()); |
797 return 0; | 798 return 0; |
798 } | 799 } |
799 | 800 |
800 if (LayoutBox* box = layoutBox()) | 801 if (LayoutBox* box = layoutBox()) |
801 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); | 802 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); |
802 return 0; | 803 return 0; |
803 } | 804 } |
804 | 805 |
805 int Element::scrollHeight() | 806 int Element::scrollHeight() |
806 { | 807 { |
807 document().updateLayoutIgnorePendingStylesheets(); | 808 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
808 | 809 |
809 if (document().scrollingElement() == this) { | 810 if (document().scrollingElement() == this) { |
810 if (document().view()) | 811 if (document().view()) |
811 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do
cument().frame()->pageZoomFactor()); | 812 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do
cument().frame()->pageZoomFactor()); |
812 return 0; | 813 return 0; |
813 } | 814 } |
814 | 815 |
815 if (LayoutBox* box = layoutBox()) | 816 if (LayoutBox* box = layoutBox()) |
816 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); | 817 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); |
817 return 0; | 818 return 0; |
818 } | 819 } |
819 | 820 |
820 void Element::scrollBy(double x, double y) | 821 void Element::scrollBy(double x, double y) |
821 { | 822 { |
822 ScrollToOptions scrollToOptions; | 823 ScrollToOptions scrollToOptions; |
823 scrollToOptions.setLeft(x); | 824 scrollToOptions.setLeft(x); |
824 scrollToOptions.setTop(y); | 825 scrollToOptions.setTop(y); |
825 scrollBy(scrollToOptions); | 826 scrollBy(scrollToOptions); |
826 } | 827 } |
827 | 828 |
828 void Element::scrollBy(const ScrollToOptions& scrollToOptions) | 829 void Element::scrollBy(const ScrollToOptions& scrollToOptions) |
829 { | 830 { |
830 // FIXME: This should be removed once scroll updates are processed only afte
r | 831 // FIXME: This should be removed once scroll updates are processed only afte
r |
831 // the compositing update. See http://crbug.com/420741. | 832 // the compositing update. See http://crbug.com/420741. |
832 document().updateLayoutIgnorePendingStylesheets(); | 833 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
833 | 834 |
834 if (document().scrollingElement() == this) { | 835 if (document().scrollingElement() == this) { |
835 scrollFrameBy(scrollToOptions); | 836 scrollFrameBy(scrollToOptions); |
836 } else { | 837 } else { |
837 scrollLayoutBoxBy(scrollToOptions); | 838 scrollLayoutBoxBy(scrollToOptions); |
838 } | 839 } |
839 } | 840 } |
840 | 841 |
841 void Element::scrollTo(double x, double y) | 842 void Element::scrollTo(double x, double y) |
842 { | 843 { |
843 ScrollToOptions scrollToOptions; | 844 ScrollToOptions scrollToOptions; |
844 scrollToOptions.setLeft(x); | 845 scrollToOptions.setLeft(x); |
845 scrollToOptions.setTop(y); | 846 scrollToOptions.setTop(y); |
846 scrollTo(scrollToOptions); | 847 scrollTo(scrollToOptions); |
847 } | 848 } |
848 | 849 |
849 void Element::scrollTo(const ScrollToOptions& scrollToOptions) | 850 void Element::scrollTo(const ScrollToOptions& scrollToOptions) |
850 { | 851 { |
851 // FIXME: This should be removed once scroll updates are processed only afte
r | 852 // FIXME: This should be removed once scroll updates are processed only afte
r |
852 // the compositing update. See http://crbug.com/420741. | 853 // the compositing update. See http://crbug.com/420741. |
853 document().updateLayoutIgnorePendingStylesheets(); | 854 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
854 | 855 |
855 if (document().scrollingElement() == this) { | 856 if (document().scrollingElement() == this) { |
856 scrollFrameTo(scrollToOptions); | 857 scrollFrameTo(scrollToOptions); |
857 } else { | 858 } else { |
858 scrollLayoutBoxTo(scrollToOptions); | 859 scrollLayoutBoxTo(scrollToOptions); |
859 } | 860 } |
860 } | 861 } |
861 | 862 |
862 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) | 863 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) |
863 { | 864 { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 996 |
996 IntRect result = quads[0].enclosingBoundingBox(); | 997 IntRect result = quads[0].enclosingBoundingBox(); |
997 for (size_t i = 1; i < quads.size(); ++i) | 998 for (size_t i = 1; i < quads.size(); ++i) |
998 result.unite(quads[i].enclosingBoundingBox()); | 999 result.unite(quads[i].enclosingBoundingBox()); |
999 | 1000 |
1000 return view->contentsToViewport(result); | 1001 return view->contentsToViewport(result); |
1001 } | 1002 } |
1002 | 1003 |
1003 ClientRectList* Element::getClientRects() | 1004 ClientRectList* Element::getClientRects() |
1004 { | 1005 { |
1005 document().updateLayoutIgnorePendingStylesheets(); | 1006 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
1006 | 1007 |
1007 LayoutObject* elementLayoutObject = layoutObject(); | 1008 LayoutObject* elementLayoutObject = layoutObject(); |
1008 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) | 1009 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) |
1009 return ClientRectList::create(); | 1010 return ClientRectList::create(); |
1010 | 1011 |
1011 // FIXME: Handle SVG elements. | 1012 // FIXME: Handle SVG elements. |
1012 // FIXME: Handle table/inline-table with a caption. | 1013 // FIXME: Handle table/inline-table with a caption. |
1013 | 1014 |
1014 Vector<FloatQuad> quads; | 1015 Vector<FloatQuad> quads; |
1015 elementLayoutObject->absoluteQuads(quads); | 1016 elementLayoutObject->absoluteQuads(quads); |
1016 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); | 1017 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); |
1017 return ClientRectList::create(quads); | 1018 return ClientRectList::create(quads); |
1018 } | 1019 } |
1019 | 1020 |
1020 ClientRect* Element::getBoundingClientRect() | 1021 ClientRect* Element::getBoundingClientRect() |
1021 { | 1022 { |
1022 document().updateLayoutIgnorePendingStylesheets(); | 1023 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
1023 | 1024 |
1024 Vector<FloatQuad> quads; | 1025 Vector<FloatQuad> quads; |
1025 LayoutObject* elementLayoutObject = layoutObject(); | 1026 LayoutObject* elementLayoutObject = layoutObject(); |
1026 if (elementLayoutObject) { | 1027 if (elementLayoutObject) { |
1027 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { | 1028 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { |
1028 // Get the bounding rectangle from the SVG model. | 1029 // Get the bounding rectangle from the SVG model. |
1029 if (toSVGElement(this)->isSVGGraphicsElement()) | 1030 if (toSVGElement(this)->isSVGGraphicsElement()) |
1030 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); | 1031 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); |
1031 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { | 1032 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { |
1032 elementLayoutObject->absoluteQuads(quads); | 1033 elementLayoutObject->absoluteQuads(quads); |
1033 } | 1034 } |
1034 } | 1035 } |
1035 | 1036 |
1036 if (quads.isEmpty()) | 1037 if (quads.isEmpty()) |
1037 return ClientRect::create(); | 1038 return ClientRect::create(); |
1038 | 1039 |
1039 FloatRect result = quads[0].boundingBox(); | 1040 FloatRect result = quads[0].boundingBox(); |
1040 for (size_t i = 1; i < quads.size(); ++i) | 1041 for (size_t i = 1; i < quads.size(); ++i) |
1041 result.unite(quads[i].boundingBox()); | 1042 result.unite(quads[i].boundingBox()); |
1042 | 1043 |
1043 ASSERT(elementLayoutObject); | 1044 ASSERT(elementLayoutObject); |
1044 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); | 1045 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); |
1045 return ClientRect::create(result); | 1046 return ClientRect::create(result); |
1046 } | 1047 } |
1047 | 1048 |
1048 const AtomicString& Element::computedRole() | 1049 const AtomicString& Element::computedRole() |
1049 { | 1050 { |
1050 document().updateLayoutIgnorePendingStylesheets(); | 1051 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
1051 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); | 1052 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); |
1052 return cache->get()->computedRoleForNode(this); | 1053 return cache->get()->computedRoleForNode(this); |
1053 } | 1054 } |
1054 | 1055 |
1055 String Element::computedName() | 1056 String Element::computedName() |
1056 { | 1057 { |
1057 document().updateLayoutIgnorePendingStylesheets(); | 1058 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
1058 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); | 1059 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); |
1059 return cache->get()->computedNameForNode(this); | 1060 return cache->get()->computedNameForNode(this); |
1060 } | 1061 } |
1061 | 1062 |
1062 const AtomicString& Element::getAttribute(const AtomicString& localName) const | 1063 const AtomicString& Element::getAttribute(const AtomicString& localName) const |
1063 { | 1064 { |
1064 if (!elementData()) | 1065 if (!elementData()) |
1065 return nullAtom; | 1066 return nullAtom; |
1066 synchronizeAttribute(localName); | 1067 synchronizeAttribute(localName); |
1067 if (const Attribute* attribute = elementData()->attributes().find(localName,
shouldIgnoreAttributeCase())) | 1068 if (const Attribute* attribute = elementData()->attributes().find(localName,
shouldIgnoreAttributeCase())) |
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2352 { | 2353 { |
2353 if (!inDocument()) | 2354 if (!inDocument()) |
2354 return; | 2355 return; |
2355 | 2356 |
2356 if (document().focusedElement() == this) | 2357 if (document().focusedElement() == this) |
2357 return; | 2358 return; |
2358 | 2359 |
2359 if (!document().isActive()) | 2360 if (!document().isActive()) |
2360 return; | 2361 return; |
2361 | 2362 |
2362 document().updateLayoutIgnorePendingStylesheets(); | 2363 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
2363 if (!isFocusable()) | 2364 if (!isFocusable()) |
2364 return; | 2365 return; |
2365 | 2366 |
2366 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { | 2367 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { |
2367 if (containsIncludingShadowDOM(document().focusedElement())) | 2368 if (containsIncludingShadowDOM(document().focusedElement())) |
2368 return; | 2369 return; |
2369 | 2370 |
2370 // Slide the focus to its inner node. | 2371 // Slide the focus to its inner node. |
2371 Element* found = document().page()->focusController().findFocusableEleme
ntInShadowHost(*this); | 2372 Element* found = document().page()->focusController().findFocusableEleme
ntInShadowHost(*this); |
2372 if (found && containsIncludingShadowDOM(found)) { | 2373 if (found && containsIncludingShadowDOM(found)) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 if (!document().frame()->eventHandler().isPointerEventActive(pointerId)) | 2663 if (!document().frame()->eventHandler().isPointerEventActive(pointerId)) |
2663 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId
"); | 2664 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId
"); |
2664 else | 2665 else |
2665 document().frame()->eventHandler().releasePointerCapture(pointerId,
this); | 2666 document().frame()->eventHandler().releasePointerCapture(pointerId,
this); |
2666 } | 2667 } |
2667 } | 2668 } |
2668 | 2669 |
2669 String Element::innerText() | 2670 String Element::innerText() |
2670 { | 2671 { |
2671 // We need to update layout, since plainText uses line boxes in the layout t
ree. | 2672 // We need to update layout, since plainText uses line boxes in the layout t
ree. |
2672 document().updateLayoutIgnorePendingStylesheets(); | 2673 document().updateLayoutIgnorePendingStylesheetsForNode(this); |
2673 | 2674 |
2674 if (!layoutObject()) | 2675 if (!layoutObject()) |
2675 return textContent(true); | 2676 return textContent(true); |
2676 | 2677 |
2677 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne
rText); | 2678 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne
rText); |
2678 } | 2679 } |
2679 | 2680 |
2680 String Element::outerText() | 2681 String Element::outerText() |
2681 { | 2682 { |
2682 // Getting outerText is the same as getting innerText, only | 2683 // Getting outerText is the same as getting innerText, only |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3669 { | 3670 { |
3670 #if ENABLE(OILPAN) | 3671 #if ENABLE(OILPAN) |
3671 if (hasRareData()) | 3672 if (hasRareData()) |
3672 visitor->trace(elementRareData()); | 3673 visitor->trace(elementRareData()); |
3673 visitor->trace(m_elementData); | 3674 visitor->trace(m_elementData); |
3674 #endif | 3675 #endif |
3675 ContainerNode::trace(visitor); | 3676 ContainerNode::trace(visitor); |
3676 } | 3677 } |
3677 | 3678 |
3678 } // namespace blink | 3679 } // namespace blink |
OLD | NEW |