| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 return nullAtom; | 431 return nullAtom; |
| 432 } | 432 } |
| 433 | 433 |
| 434 bool Element::shouldIgnoreAttributeCase() const | 434 bool Element::shouldIgnoreAttributeCase() const |
| 435 { | 435 { |
| 436 return isHTMLElement() && document().isHTMLDocument(); | 436 return isHTMLElement() && document().isHTMLDocument(); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void Element::scrollIntoView(bool alignToTop) | 439 void Element::scrollIntoView(bool alignToTop) |
| 440 { | 440 { |
| 441 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 441 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 442 | 442 |
| 443 if (!layoutObject()) | 443 if (!layoutObject()) |
| 444 return; | 444 return; |
| 445 | 445 |
| 446 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); | 446 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); |
| 447 | 447 |
| 448 LayoutRect bounds = boundingBox(); | 448 LayoutRect bounds = boundingBox(); |
| 449 // Align to the top / bottom and to the closest edge. | 449 // Align to the top / bottom and to the closest edge. |
| 450 if (alignToTop) | 450 if (alignToTop) |
| 451 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignTopAlways, ProgrammaticScroll, makeVisibleInVisu
alViewport); | 451 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignTopAlways, ProgrammaticScroll, makeVisibleInVisu
alViewport); |
| 452 else | 452 else |
| 453 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignBottomAlways, ProgrammaticScroll, makeVisibleInV
isualViewport); | 453 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignBottomAlways, ProgrammaticScroll, makeVisibleInV
isualViewport); |
| 454 | 454 |
| 455 document().setSequentialFocusNavigationStartingPoint(this); | 455 document().setSequentialFocusNavigationStartingPoint(this); |
| 456 } | 456 } |
| 457 | 457 |
| 458 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) | 458 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) |
| 459 { | 459 { |
| 460 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 460 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 461 | 461 |
| 462 if (!layoutObject()) | 462 if (!layoutObject()) |
| 463 return; | 463 return; |
| 464 | 464 |
| 465 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); | 465 bool makeVisibleInVisualViewport = !document().page()->settings().inertVisua
lViewport(); |
| 466 | 466 |
| 467 LayoutRect bounds = boundingBox(); | 467 LayoutRect bounds = boundingBox(); |
| 468 if (centerIfNeeded) | 468 if (centerIfNeeded) |
| 469 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded, ProgrammaticScroll, makeVisibleI
nVisualViewport); | 469 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded, ProgrammaticScroll, makeVisibleI
nVisualViewport); |
| 470 else | 470 else |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 DCHECK(!layoutObject() || layoutObject()->isBox()); | 541 DCHECK(!layoutObject() || layoutObject()->isBox()); |
| 542 | 542 |
| 543 if (scrollState.fullyConsumed()) | 543 if (scrollState.fullyConsumed()) |
| 544 return; | 544 return; |
| 545 | 545 |
| 546 FloatSize delta(scrollState.deltaX(), scrollState.deltaY()); | 546 FloatSize delta(scrollState.deltaX(), scrollState.deltaY()); |
| 547 | 547 |
| 548 if (delta.isZero()) | 548 if (delta.isZero()) |
| 549 return; | 549 return; |
| 550 | 550 |
| 551 // TODO(esprehn): This should use updateLayoutIgnorePendingStylesheetsForNod
e. | 551 // TODO(esprehn): This should use updateStyleAndLayoutIgnorePendingStyleshee
tsForNode. |
| 552 document().updateLayoutIgnorePendingStylesheets(); | 552 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 553 | 553 |
| 554 LayoutBox* boxToScroll = nullptr; | 554 LayoutBox* boxToScroll = nullptr; |
| 555 | 555 |
| 556 // Handle the scrollingElement separately, as it should scroll the viewport. | 556 // Handle the scrollingElement separately, as it should scroll the viewport. |
| 557 if (this == document().scrollingElement()) | 557 if (this == document().scrollingElement()) |
| 558 boxToScroll = document().layoutView(); | 558 boxToScroll = document().layoutView(); |
| 559 else if (layoutObject()) | 559 else if (layoutObject()) |
| 560 boxToScroll = toLayoutBox(layoutObject()); | 560 boxToScroll = toLayoutBox(layoutObject()); |
| 561 | 561 |
| 562 if (!boxToScroll) | 562 if (!boxToScroll) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte
rNativeScroll) | 595 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::PerformAfte
rNativeScroll) |
| 596 callback->handleEvent(&scrollState); | 596 callback->handleEvent(&scrollState); |
| 597 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati
veScroll) | 597 if (callback->nativeScrollBehavior() != WebNativeScrollBehavior::DisableNati
veScroll) |
| 598 nativeApplyScroll(scrollState); | 598 nativeApplyScroll(scrollState); |
| 599 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte
rNativeScroll) | 599 if (callback->nativeScrollBehavior() == WebNativeScrollBehavior::PerformAfte
rNativeScroll) |
| 600 callback->handleEvent(&scrollState); | 600 callback->handleEvent(&scrollState); |
| 601 }; | 601 }; |
| 602 | 602 |
| 603 int Element::offsetLeft() | 603 int Element::offsetLeft() |
| 604 { | 604 { |
| 605 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 605 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 606 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 606 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| 607 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetLeft()), layoutObject->styleRef()).round(); | 607 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetLeft()), layoutObject->styleRef()).round(); |
| 608 return 0; | 608 return 0; |
| 609 } | 609 } |
| 610 | 610 |
| 611 int Element::offsetTop() | 611 int Element::offsetTop() |
| 612 { | 612 { |
| 613 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 613 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 614 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 614 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| 615 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetTop()), layoutObject->styleRef()).round(); | 615 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetTop()), layoutObject->styleRef()).round(); |
| 616 return 0; | 616 return 0; |
| 617 } | 617 } |
| 618 | 618 |
| 619 int Element::offsetWidth() | 619 int Element::offsetWidth() |
| 620 { | 620 { |
| 621 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 621 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 622 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 622 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| 623 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetWidth()), layoutObject->styleRef()).round(); | 623 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetWidth()), layoutObject->styleRef()).round(); |
| 624 return 0; | 624 return 0; |
| 625 } | 625 } |
| 626 | 626 |
| 627 int Element::offsetHeight() | 627 int Element::offsetHeight() |
| 628 { | 628 { |
| 629 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 629 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 630 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 630 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
| 631 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetHeight()), layoutObject->styleRef()).round(); | 631 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedOffsetHeight()), layoutObject->styleRef()).round(); |
| 632 return 0; | 632 return 0; |
| 633 } | 633 } |
| 634 | 634 |
| 635 Element* Element::offsetParent() | 635 Element* Element::offsetParent() |
| 636 { | 636 { |
| 637 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 637 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 638 | 638 |
| 639 LayoutObject* layoutObject = this->layoutObject(); | 639 LayoutObject* layoutObject = this->layoutObject(); |
| 640 if (!layoutObject) | 640 if (!layoutObject) |
| 641 return nullptr; | 641 return nullptr; |
| 642 | 642 |
| 643 Element* element = layoutObject->offsetParent(); | 643 Element* element = layoutObject->offsetParent(); |
| 644 if (!element) | 644 if (!element) |
| 645 return nullptr; | 645 return nullptr; |
| 646 | 646 |
| 647 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpenOrV
0()) | 647 if (element->isInShadowTree() && !element->containingShadowRoot()->isOpenOrV
0()) |
| 648 return nullptr; | 648 return nullptr; |
| 649 | 649 |
| 650 return element; | 650 return element; |
| 651 } | 651 } |
| 652 | 652 |
| 653 int Element::clientLeft() | 653 int Element::clientLeft() |
| 654 { | 654 { |
| 655 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 655 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 656 | 656 |
| 657 if (LayoutBox* layoutObject = layoutBox()) | 657 if (LayoutBox* layoutObject = layoutBox()) |
| 658 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientLeft(), layou
tObject->styleRef()).round(); | 658 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientLeft(), layou
tObject->styleRef()).round(); |
| 659 return 0; | 659 return 0; |
| 660 } | 660 } |
| 661 | 661 |
| 662 int Element::clientTop() | 662 int Element::clientTop() |
| 663 { | 663 { |
| 664 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 664 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 665 | 665 |
| 666 if (LayoutBox* layoutObject = layoutBox()) | 666 if (LayoutBox* layoutObject = layoutBox()) |
| 667 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientTop(), layout
Object->styleRef()).round(); | 667 return adjustLayoutUnitForAbsoluteZoom(layoutObject->clientTop(), layout
Object->styleRef()).round(); |
| 668 return 0; | 668 return 0; |
| 669 } | 669 } |
| 670 | 670 |
| 671 int Element::clientWidth() | 671 int Element::clientWidth() |
| 672 { | 672 { |
| 673 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 673 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 674 | 674 |
| 675 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. | 675 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. |
| 676 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. | 676 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. |
| 677 bool inQuirksMode = document().inQuirksMode(); | 677 bool inQuirksMode = document().inQuirksMode(); |
| 678 if ((!inQuirksMode && document().documentElement() == this) | 678 if ((!inQuirksMode && document().documentElement() == this) |
| 679 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 679 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
| 680 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ | 680 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ |
| 681 if (document().page()->settings().forceZeroLayoutHeight()) | 681 if (document().page()->settings().forceZeroLayoutHeight()) |
| 682 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).width(), layoutView.styleRef()).round(); | 682 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).width(), layoutView.styleRef()).round(); |
| 683 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().width()), layoutView.styleRef()).round(); | 683 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().width()), layoutView.styleRef()).round(); |
| 684 } | 684 } |
| 685 } | 685 } |
| 686 | 686 |
| 687 if (LayoutBox* layoutObject = layoutBox()) | 687 if (LayoutBox* layoutObject = layoutBox()) |
| 688 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientWidth()), layoutObject->styleRef()).round(); | 688 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientWidth()), layoutObject->styleRef()).round(); |
| 689 return 0; | 689 return 0; |
| 690 } | 690 } |
| 691 | 691 |
| 692 int Element::clientHeight() | 692 int Element::clientHeight() |
| 693 { | 693 { |
| 694 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 694 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 695 | 695 |
| 696 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. | 696 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. |
| 697 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. | 697 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. |
| 698 bool inQuirksMode = document().inQuirksMode(); | 698 bool inQuirksMode = document().inQuirksMode(); |
| 699 | 699 |
| 700 if ((!inQuirksMode && document().documentElement() == this) | 700 if ((!inQuirksMode && document().documentElement() == this) |
| 701 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 701 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
| 702 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ | 702 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ |
| 703 if (document().page()->settings().forceZeroLayoutHeight()) | 703 if (document().page()->settings().forceZeroLayoutHeight()) |
| 704 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).height(), layoutView.styleRef()).round(); | 704 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).height(), layoutView.styleRef()).round(); |
| 705 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().height()), layoutView.styleRef()).round(); | 705 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().height()), layoutView.styleRef()).round(); |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 | 708 |
| 709 if (LayoutBox* layoutObject = layoutBox()) | 709 if (LayoutBox* layoutObject = layoutBox()) |
| 710 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientHeight()), layoutObject->styleRef()).round(); | 710 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientHeight()), layoutObject->styleRef()).round(); |
| 711 return 0; | 711 return 0; |
| 712 } | 712 } |
| 713 | 713 |
| 714 double Element::scrollLeft() | 714 double Element::scrollLeft() |
| 715 { | 715 { |
| 716 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 716 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 717 | 717 |
| 718 if (document().scrollingElement() == this) { | 718 if (document().scrollingElement() == this) { |
| 719 if (document().domWindow()) | 719 if (document().domWindow()) |
| 720 return document().domWindow()->scrollX(); | 720 return document().domWindow()->scrollX(); |
| 721 return 0; | 721 return 0; |
| 722 } | 722 } |
| 723 | 723 |
| 724 if (LayoutBox* box = layoutBox()) | 724 if (LayoutBox* box = layoutBox()) |
| 725 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); | 725 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); |
| 726 | 726 |
| 727 return 0; | 727 return 0; |
| 728 } | 728 } |
| 729 | 729 |
| 730 double Element::scrollTop() | 730 double Element::scrollTop() |
| 731 { | 731 { |
| 732 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 732 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 733 | 733 |
| 734 if (document().scrollingElement() == this) { | 734 if (document().scrollingElement() == this) { |
| 735 if (document().domWindow()) | 735 if (document().domWindow()) |
| 736 return document().domWindow()->scrollY(); | 736 return document().domWindow()->scrollY(); |
| 737 return 0; | 737 return 0; |
| 738 } | 738 } |
| 739 | 739 |
| 740 if (LayoutBox* box = layoutBox()) | 740 if (LayoutBox* box = layoutBox()) |
| 741 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); | 741 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); |
| 742 | 742 |
| 743 return 0; | 743 return 0; |
| 744 } | 744 } |
| 745 | 745 |
| 746 void Element::setScrollLeft(double newLeft) | 746 void Element::setScrollLeft(double newLeft) |
| 747 { | 747 { |
| 748 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 748 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 749 | 749 |
| 750 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); | 750 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); |
| 751 | 751 |
| 752 if (document().scrollingElement() == this) { | 752 if (document().scrollingElement() == this) { |
| 753 if (LocalDOMWindow* window = document().domWindow()) | 753 if (LocalDOMWindow* window = document().domWindow()) |
| 754 window->scrollTo(newLeft, window->scrollY()); | 754 window->scrollTo(newLeft, window->scrollY()); |
| 755 } else { | 755 } else { |
| 756 LayoutBox* box = layoutBox(); | 756 LayoutBox* box = layoutBox(); |
| 757 if (box) | 757 if (box) |
| 758 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()
->effectiveZoom())); | 758 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()
->effectiveZoom())); |
| 759 } | 759 } |
| 760 } | 760 } |
| 761 | 761 |
| 762 void Element::setScrollTop(double newTop) | 762 void Element::setScrollTop(double newTop) |
| 763 { | 763 { |
| 764 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 764 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 765 | 765 |
| 766 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); | 766 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); |
| 767 | 767 |
| 768 if (document().scrollingElement() == this) { | 768 if (document().scrollingElement() == this) { |
| 769 if (LocalDOMWindow* window = document().domWindow()) | 769 if (LocalDOMWindow* window = document().domWindow()) |
| 770 window->scrollTo(window->scrollX(), newTop); | 770 window->scrollTo(window->scrollX(), newTop); |
| 771 } else { | 771 } else { |
| 772 LayoutBox* box = layoutBox(); | 772 LayoutBox* box = layoutBox(); |
| 773 if (box) | 773 if (box) |
| 774 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->
effectiveZoom())); | 774 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->
effectiveZoom())); |
| 775 } | 775 } |
| 776 } | 776 } |
| 777 | 777 |
| 778 int Element::scrollWidth() | 778 int Element::scrollWidth() |
| 779 { | 779 { |
| 780 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 780 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 781 | 781 |
| 782 if (document().scrollingElement() == this) { | 782 if (document().scrollingElement() == this) { |
| 783 if (document().view()) | 783 if (document().view()) |
| 784 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc
ument().frame()->pageZoomFactor()); | 784 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc
ument().frame()->pageZoomFactor()); |
| 785 return 0; | 785 return 0; |
| 786 } | 786 } |
| 787 | 787 |
| 788 if (LayoutBox* box = layoutBox()) | 788 if (LayoutBox* box = layoutBox()) |
| 789 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); | 789 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); |
| 790 return 0; | 790 return 0; |
| 791 } | 791 } |
| 792 | 792 |
| 793 int Element::scrollHeight() | 793 int Element::scrollHeight() |
| 794 { | 794 { |
| 795 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 795 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 796 | 796 |
| 797 if (document().scrollingElement() == this) { | 797 if (document().scrollingElement() == this) { |
| 798 if (document().view()) | 798 if (document().view()) |
| 799 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do
cument().frame()->pageZoomFactor()); | 799 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do
cument().frame()->pageZoomFactor()); |
| 800 return 0; | 800 return 0; |
| 801 } | 801 } |
| 802 | 802 |
| 803 if (LayoutBox* box = layoutBox()) | 803 if (LayoutBox* box = layoutBox()) |
| 804 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); | 804 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); |
| 805 return 0; | 805 return 0; |
| 806 } | 806 } |
| 807 | 807 |
| 808 void Element::scrollBy(double x, double y) | 808 void Element::scrollBy(double x, double y) |
| 809 { | 809 { |
| 810 ScrollToOptions scrollToOptions; | 810 ScrollToOptions scrollToOptions; |
| 811 scrollToOptions.setLeft(x); | 811 scrollToOptions.setLeft(x); |
| 812 scrollToOptions.setTop(y); | 812 scrollToOptions.setTop(y); |
| 813 scrollBy(scrollToOptions); | 813 scrollBy(scrollToOptions); |
| 814 } | 814 } |
| 815 | 815 |
| 816 void Element::scrollBy(const ScrollToOptions& scrollToOptions) | 816 void Element::scrollBy(const ScrollToOptions& scrollToOptions) |
| 817 { | 817 { |
| 818 // FIXME: This should be removed once scroll updates are processed only afte
r | 818 // FIXME: This should be removed once scroll updates are processed only afte
r |
| 819 // the compositing update. See http://crbug.com/420741. | 819 // the compositing update. See http://crbug.com/420741. |
| 820 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 820 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 821 | 821 |
| 822 if (document().scrollingElement() == this) { | 822 if (document().scrollingElement() == this) { |
| 823 scrollFrameBy(scrollToOptions); | 823 scrollFrameBy(scrollToOptions); |
| 824 } else { | 824 } else { |
| 825 scrollLayoutBoxBy(scrollToOptions); | 825 scrollLayoutBoxBy(scrollToOptions); |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 | 828 |
| 829 void Element::scrollTo(double x, double y) | 829 void Element::scrollTo(double x, double y) |
| 830 { | 830 { |
| 831 ScrollToOptions scrollToOptions; | 831 ScrollToOptions scrollToOptions; |
| 832 scrollToOptions.setLeft(x); | 832 scrollToOptions.setLeft(x); |
| 833 scrollToOptions.setTop(y); | 833 scrollToOptions.setTop(y); |
| 834 scrollTo(scrollToOptions); | 834 scrollTo(scrollToOptions); |
| 835 } | 835 } |
| 836 | 836 |
| 837 void Element::scrollTo(const ScrollToOptions& scrollToOptions) | 837 void Element::scrollTo(const ScrollToOptions& scrollToOptions) |
| 838 { | 838 { |
| 839 // FIXME: This should be removed once scroll updates are processed only afte
r | 839 // FIXME: This should be removed once scroll updates are processed only afte
r |
| 840 // the compositing update. See http://crbug.com/420741. | 840 // the compositing update. See http://crbug.com/420741. |
| 841 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 841 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 842 | 842 |
| 843 if (document().scrollingElement() == this) { | 843 if (document().scrollingElement() == this) { |
| 844 scrollFrameTo(scrollToOptions); | 844 scrollFrameTo(scrollToOptions); |
| 845 } else { | 845 } else { |
| 846 scrollLayoutBoxTo(scrollToOptions); | 846 scrollLayoutBoxTo(scrollToOptions); |
| 847 } | 847 } |
| 848 } | 848 } |
| 849 | 849 |
| 850 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) | 850 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) |
| 851 { | 851 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 { | 952 { |
| 953 if (!hasRareData()) | 953 if (!hasRareData()) |
| 954 return CompositorMutableProperty::kNone; | 954 return CompositorMutableProperty::kNone; |
| 955 if (CompositorProxiedPropertySet* set = elementRareData()->proxiedPropertyCo
unts()) | 955 if (CompositorProxiedPropertySet* set = elementRareData()->proxiedPropertyCo
unts()) |
| 956 return set->proxiedProperties(); | 956 return set->proxiedProperties(); |
| 957 return CompositorMutableProperty::kNone; | 957 return CompositorMutableProperty::kNone; |
| 958 } | 958 } |
| 959 | 959 |
| 960 bool Element::hasNonEmptyLayoutSize() const | 960 bool Element::hasNonEmptyLayoutSize() const |
| 961 { | 961 { |
| 962 document().updateLayoutIgnorePendingStylesheets(); | 962 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 963 | 963 |
| 964 if (LayoutBoxModelObject* box = layoutBoxModelObject()) | 964 if (LayoutBoxModelObject* box = layoutBoxModelObject()) |
| 965 return box->hasNonEmptyLayoutSize(); | 965 return box->hasNonEmptyLayoutSize(); |
| 966 return false; | 966 return false; |
| 967 } | 967 } |
| 968 | 968 |
| 969 IntRect Element::boundsInViewport() const | 969 IntRect Element::boundsInViewport() const |
| 970 { | 970 { |
| 971 document().updateLayoutIgnorePendingStylesheets(); | 971 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 972 | 972 |
| 973 FrameView* view = document().view(); | 973 FrameView* view = document().view(); |
| 974 if (!view) | 974 if (!view) |
| 975 return IntRect(); | 975 return IntRect(); |
| 976 | 976 |
| 977 Vector<FloatQuad> quads; | 977 Vector<FloatQuad> quads; |
| 978 if (isSVGElement() && layoutObject()) { | 978 if (isSVGElement() && layoutObject()) { |
| 979 // Get the bounding rectangle from the SVG model. | 979 // Get the bounding rectangle from the SVG model. |
| 980 if (toSVGElement(this)->isSVGGraphicsElement()) | 980 if (toSVGElement(this)->isSVGGraphicsElement()) |
| 981 quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->obj
ectBoundingBox())); | 981 quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->obj
ectBoundingBox())); |
| 982 } else { | 982 } else { |
| 983 // Get the bounding rectangle from the box model. | 983 // Get the bounding rectangle from the box model. |
| 984 if (layoutBoxModelObject()) | 984 if (layoutBoxModelObject()) |
| 985 layoutBoxModelObject()->absoluteQuads(quads); | 985 layoutBoxModelObject()->absoluteQuads(quads); |
| 986 } | 986 } |
| 987 | 987 |
| 988 if (quads.isEmpty()) | 988 if (quads.isEmpty()) |
| 989 return IntRect(); | 989 return IntRect(); |
| 990 | 990 |
| 991 IntRect result = quads[0].enclosingBoundingBox(); | 991 IntRect result = quads[0].enclosingBoundingBox(); |
| 992 for (size_t i = 1; i < quads.size(); ++i) | 992 for (size_t i = 1; i < quads.size(); ++i) |
| 993 result.unite(quads[i].enclosingBoundingBox()); | 993 result.unite(quads[i].enclosingBoundingBox()); |
| 994 | 994 |
| 995 return view->contentsToViewport(result); | 995 return view->contentsToViewport(result); |
| 996 } | 996 } |
| 997 | 997 |
| 998 ClientRectList* Element::getClientRects() | 998 ClientRectList* Element::getClientRects() |
| 999 { | 999 { |
| 1000 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1000 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1001 | 1001 |
| 1002 LayoutObject* elementLayoutObject = layoutObject(); | 1002 LayoutObject* elementLayoutObject = layoutObject(); |
| 1003 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) | 1003 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) |
| 1004 return ClientRectList::create(); | 1004 return ClientRectList::create(); |
| 1005 | 1005 |
| 1006 // FIXME: Handle SVG elements. | 1006 // FIXME: Handle SVG elements. |
| 1007 // FIXME: Handle table/inline-table with a caption. | 1007 // FIXME: Handle table/inline-table with a caption. |
| 1008 | 1008 |
| 1009 Vector<FloatQuad> quads; | 1009 Vector<FloatQuad> quads; |
| 1010 elementLayoutObject->absoluteQuads(quads); | 1010 elementLayoutObject->absoluteQuads(quads); |
| 1011 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); | 1011 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); |
| 1012 return ClientRectList::create(quads); | 1012 return ClientRectList::create(quads); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 ClientRect* Element::getBoundingClientRect() | 1015 ClientRect* Element::getBoundingClientRect() |
| 1016 { | 1016 { |
| 1017 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1017 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1018 | 1018 |
| 1019 Vector<FloatQuad> quads; | 1019 Vector<FloatQuad> quads; |
| 1020 LayoutObject* elementLayoutObject = layoutObject(); | 1020 LayoutObject* elementLayoutObject = layoutObject(); |
| 1021 if (elementLayoutObject) { | 1021 if (elementLayoutObject) { |
| 1022 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { | 1022 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { |
| 1023 // Get the bounding rectangle from the SVG model. | 1023 // Get the bounding rectangle from the SVG model. |
| 1024 if (toSVGElement(this)->isSVGGraphicsElement()) | 1024 if (toSVGElement(this)->isSVGGraphicsElement()) |
| 1025 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); | 1025 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); |
| 1026 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { | 1026 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { |
| 1027 elementLayoutObject->absoluteQuads(quads); | 1027 elementLayoutObject->absoluteQuads(quads); |
| 1028 } | 1028 } |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 if (quads.isEmpty()) | 1031 if (quads.isEmpty()) |
| 1032 return ClientRect::create(); | 1032 return ClientRect::create(); |
| 1033 | 1033 |
| 1034 FloatRect result = quads[0].boundingBox(); | 1034 FloatRect result = quads[0].boundingBox(); |
| 1035 for (size_t i = 1; i < quads.size(); ++i) | 1035 for (size_t i = 1; i < quads.size(); ++i) |
| 1036 result.unite(quads[i].boundingBox()); | 1036 result.unite(quads[i].boundingBox()); |
| 1037 | 1037 |
| 1038 DCHECK(elementLayoutObject); | 1038 DCHECK(elementLayoutObject); |
| 1039 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); | 1039 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); |
| 1040 return ClientRect::create(result); | 1040 return ClientRect::create(result); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 const AtomicString& Element::computedRole() | 1043 const AtomicString& Element::computedRole() |
| 1044 { | 1044 { |
| 1045 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1045 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1046 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); | 1046 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); |
| 1047 return cache->get()->computedRoleForNode(this); | 1047 return cache->get()->computedRoleForNode(this); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 String Element::computedName() | 1050 String Element::computedName() |
| 1051 { | 1051 { |
| 1052 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1052 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1053 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); | 1053 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); |
| 1054 return cache->get()->computedNameForNode(this); | 1054 return cache->get()->computedNameForNode(this); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 const AtomicString& Element::getAttribute(const AtomicString& localName) const | 1057 const AtomicString& Element::getAttribute(const AtomicString& localName) const |
| 1058 { | 1058 { |
| 1059 if (!elementData()) | 1059 if (!elementData()) |
| 1060 return nullAtom; | 1060 return nullAtom; |
| 1061 synchronizeAttribute(localName); | 1061 synchronizeAttribute(localName); |
| 1062 if (const Attribute* attribute = elementData()->attributes().find(localName,
shouldIgnoreAttributeCase())) | 1062 if (const Attribute* attribute = elementData()->attributes().find(localName,
shouldIgnoreAttributeCase())) |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 { | 2366 { |
| 2367 if (!inShadowIncludingDocument()) | 2367 if (!inShadowIncludingDocument()) |
| 2368 return; | 2368 return; |
| 2369 | 2369 |
| 2370 if (document().focusedElement() == this) | 2370 if (document().focusedElement() == this) |
| 2371 return; | 2371 return; |
| 2372 | 2372 |
| 2373 if (!document().isActive()) | 2373 if (!document().isActive()) |
| 2374 return; | 2374 return; |
| 2375 | 2375 |
| 2376 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 2376 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 2377 if (!isFocusable()) | 2377 if (!isFocusable()) |
| 2378 return; | 2378 return; |
| 2379 | 2379 |
| 2380 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { | 2380 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { |
| 2381 if (isShadowIncludingInclusiveAncestorOf(document().focusedElement())) | 2381 if (isShadowIncludingInclusiveAncestorOf(document().focusedElement())) |
| 2382 return; | 2382 return; |
| 2383 | 2383 |
| 2384 // Slide the focus to its inner node. | 2384 // Slide the focus to its inner node. |
| 2385 Element* found = document().page()->focusController().findFocusableEleme
ntInShadowHost(*this); | 2385 Element* found = document().page()->focusController().findFocusableEleme
ntInShadowHost(*this); |
| 2386 if (found && isShadowIncludingInclusiveAncestorOf(found)) { | 2386 if (found && isShadowIncludingInclusiveAncestorOf(found)) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2685 else if (document().frame()->eventHandler().getPointerEventType(pointerI
d) == WebPointerProperties::PointerType::Touch) | 2685 else if (document().frame()->eventHandler().getPointerEventType(pointerI
d) == WebPointerProperties::PointerType::Touch) |
| 2686 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId
"); | 2686 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId
"); |
| 2687 else | 2687 else |
| 2688 document().frame()->eventHandler().releasePointerCapture(pointerId,
this); | 2688 document().frame()->eventHandler().releasePointerCapture(pointerId,
this); |
| 2689 } | 2689 } |
| 2690 } | 2690 } |
| 2691 | 2691 |
| 2692 String Element::innerText() | 2692 String Element::innerText() |
| 2693 { | 2693 { |
| 2694 // We need to update layout, since plainText uses line boxes in the layout t
ree. | 2694 // We need to update layout, since plainText uses line boxes in the layout t
ree. |
| 2695 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 2695 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 2696 | 2696 |
| 2697 if (!layoutObject()) | 2697 if (!layoutObject()) |
| 2698 return textContent(true); | 2698 return textContent(true); |
| 2699 | 2699 |
| 2700 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne
rText); | 2700 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne
rText); |
| 2701 } | 2701 } |
| 2702 | 2702 |
| 2703 String Element::outerText() | 2703 String Element::outerText() |
| 2704 { | 2704 { |
| 2705 // Getting outerText is the same as getting innerText, only | 2705 // Getting outerText is the same as getting innerText, only |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3695 | 3695 |
| 3696 DEFINE_TRACE(Element) | 3696 DEFINE_TRACE(Element) |
| 3697 { | 3697 { |
| 3698 if (hasRareData()) | 3698 if (hasRareData()) |
| 3699 visitor->trace(elementRareData()); | 3699 visitor->trace(elementRareData()); |
| 3700 visitor->trace(m_elementData); | 3700 visitor->trace(m_elementData); |
| 3701 ContainerNode::trace(visitor); | 3701 ContainerNode::trace(visitor); |
| 3702 } | 3702 } |
| 3703 | 3703 |
| 3704 } // namespace blink | 3704 } // namespace blink |
| OLD | NEW |