| 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 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. | 673 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. |
| 674 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. | 674 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. |
| 675 bool inQuirksMode = document().inQuirksMode(); | 675 bool inQuirksMode = document().inQuirksMode(); |
| 676 if ((!inQuirksMode && document().documentElement() == this) | 676 if ((!inQuirksMode && document().documentElement() == this) |
| 677 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 677 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
| 678 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ | 678 if (LayoutViewItem layoutView = LayoutViewItem(document().layoutView()))
{ |
| 679 if (!RuntimeEnabledFeatures::overlayScrollbarsEnabled() || !document
().frame()->isLocalRoot()) | 679 if (!RuntimeEnabledFeatures::overlayScrollbarsEnabled() || !document
().frame()->isLocalRoot()) |
| 680 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 680 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(t
his); |
| 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 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 687 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 688 | 688 |
| 689 if (LayoutBox* layoutObject = layoutBox()) | 689 if (LayoutBox* layoutObject = layoutBox()) |
| 690 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientWidth()), layoutObject->styleRef()).round(); | 690 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientWidth()), layoutObject->styleRef()).round(); |
| 691 return 0; | 691 return 0; |
| 692 } | 692 } |
| 693 | 693 |
| 694 int Element::clientHeight() | 694 int Element::clientHeight() |
| 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 (!RuntimeEnabledFeatures::overlayScrollbarsEnabled() || !document
().frame()->isLocalRoot()) | 703 if (!RuntimeEnabledFeatures::overlayScrollbarsEnabled() || !document
().frame()->isLocalRoot()) |
| 704 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 704 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(t
his); |
| 705 if (document().page()->settings().forceZeroLayoutHeight()) | 705 if (document().page()->settings().forceZeroLayoutHeight()) |
| 706 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).height(), layoutView.styleRef()).round(); | 706 return adjustLayoutUnitForAbsoluteZoom(layoutView.overflowClipRe
ct(LayoutPoint()).height(), layoutView.styleRef()).round(); |
| 707 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().height()), layoutView.styleRef()).round(); | 707 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutView.layoutS
ize().height()), layoutView.styleRef()).round(); |
| 708 } | 708 } |
| 709 } | 709 } |
| 710 | 710 |
| 711 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 711 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 712 | 712 |
| 713 if (LayoutBox* layoutObject = layoutBox()) | 713 if (LayoutBox* layoutObject = layoutBox()) |
| 714 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientHeight()), layoutObject->styleRef()).round(); | 714 return adjustLayoutUnitForAbsoluteZoom(LayoutUnit(layoutObject->pixelSna
ppedClientHeight()), layoutObject->styleRef()).round(); |
| 715 return 0; | 715 return 0; |
| 716 } | 716 } |
| 717 | 717 |
| 718 double Element::scrollLeft() | 718 double Element::scrollLeft() |
| 719 { | 719 { |
| 720 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 720 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 721 | 721 |
| 722 if (document().scrollingElement() == this) { | 722 if (document().scrollingElement() == this) { |
| 723 if (document().domWindow()) | 723 if (document().domWindow()) |
| 724 return document().domWindow()->scrollX(); | 724 return document().domWindow()->scrollX(); |
| 725 return 0; | 725 return 0; |
| 726 } | 726 } |
| 727 | 727 |
| 728 if (LayoutBox* box = layoutBox()) | 728 if (LayoutBox* box = layoutBox()) |
| 729 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); | 729 return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); |
| 730 | 730 |
| 731 return 0; | 731 return 0; |
| 732 } | 732 } |
| 733 | 733 |
| 734 double Element::scrollTop() | 734 double Element::scrollTop() |
| 735 { | 735 { |
| 736 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 736 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 737 | 737 |
| 738 if (document().scrollingElement() == this) { | 738 if (document().scrollingElement() == this) { |
| 739 if (document().domWindow()) | 739 if (document().domWindow()) |
| 740 return document().domWindow()->scrollY(); | 740 return document().domWindow()->scrollY(); |
| 741 return 0; | 741 return 0; |
| 742 } | 742 } |
| 743 | 743 |
| 744 if (LayoutBox* box = layoutBox()) | 744 if (LayoutBox* box = layoutBox()) |
| 745 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); | 745 return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); |
| 746 | 746 |
| 747 return 0; | 747 return 0; |
| 748 } | 748 } |
| 749 | 749 |
| 750 void Element::setScrollLeft(double newLeft) | 750 void Element::setScrollLeft(double newLeft) |
| 751 { | 751 { |
| 752 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 752 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 753 | 753 |
| 754 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); | 754 newLeft = ScrollableArea::normalizeNonFiniteScroll(newLeft); |
| 755 | 755 |
| 756 if (document().scrollingElement() == this) { | 756 if (document().scrollingElement() == this) { |
| 757 if (LocalDOMWindow* window = document().domWindow()) | 757 if (LocalDOMWindow* window = document().domWindow()) |
| 758 window->scrollTo(newLeft, window->scrollY()); | 758 window->scrollTo(newLeft, window->scrollY()); |
| 759 } else { | 759 } else { |
| 760 LayoutBox* box = layoutBox(); | 760 LayoutBox* box = layoutBox(); |
| 761 if (box) | 761 if (box) |
| 762 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()
->effectiveZoom())); | 762 box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()
->effectiveZoom())); |
| 763 } | 763 } |
| 764 } | 764 } |
| 765 | 765 |
| 766 void Element::setScrollTop(double newTop) | 766 void Element::setScrollTop(double newTop) |
| 767 { | 767 { |
| 768 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 768 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 769 | 769 |
| 770 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); | 770 newTop = ScrollableArea::normalizeNonFiniteScroll(newTop); |
| 771 | 771 |
| 772 if (document().scrollingElement() == this) { | 772 if (document().scrollingElement() == this) { |
| 773 if (LocalDOMWindow* window = document().domWindow()) | 773 if (LocalDOMWindow* window = document().domWindow()) |
| 774 window->scrollTo(window->scrollX(), newTop); | 774 window->scrollTo(window->scrollX(), newTop); |
| 775 } else { | 775 } else { |
| 776 LayoutBox* box = layoutBox(); | 776 LayoutBox* box = layoutBox(); |
| 777 if (box) | 777 if (box) |
| 778 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->
effectiveZoom())); | 778 box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->
effectiveZoom())); |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 | 781 |
| 782 int Element::scrollWidth() | 782 int Element::scrollWidth() |
| 783 { | 783 { |
| 784 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 784 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 785 | 785 |
| 786 if (document().scrollingElement() == this) { | 786 if (document().scrollingElement() == this) { |
| 787 if (document().view()) | 787 if (document().view()) |
| 788 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc
ument().frame()->pageZoomFactor()); | 788 return adjustForAbsoluteZoom(document().view()->contentsWidth(), doc
ument().frame()->pageZoomFactor()); |
| 789 return 0; | 789 return 0; |
| 790 } | 790 } |
| 791 | 791 |
| 792 if (LayoutBox* box = layoutBox()) | 792 if (LayoutBox* box = layoutBox()) |
| 793 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); | 793 return adjustForAbsoluteZoom(box->pixelSnappedScrollWidth(), box); |
| 794 return 0; | 794 return 0; |
| 795 } | 795 } |
| 796 | 796 |
| 797 int Element::scrollHeight() | 797 int Element::scrollHeight() |
| 798 { | 798 { |
| 799 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 799 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 800 | 800 |
| 801 if (document().scrollingElement() == this) { | 801 if (document().scrollingElement() == this) { |
| 802 if (document().view()) | 802 if (document().view()) |
| 803 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do
cument().frame()->pageZoomFactor()); | 803 return adjustForAbsoluteZoom(document().view()->contentsHeight(), do
cument().frame()->pageZoomFactor()); |
| 804 return 0; | 804 return 0; |
| 805 } | 805 } |
| 806 | 806 |
| 807 if (LayoutBox* box = layoutBox()) | 807 if (LayoutBox* box = layoutBox()) |
| 808 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); | 808 return adjustForAbsoluteZoom(box->pixelSnappedScrollHeight(), box); |
| 809 return 0; | 809 return 0; |
| 810 } | 810 } |
| 811 | 811 |
| 812 void Element::scrollBy(double x, double y) | 812 void Element::scrollBy(double x, double y) |
| 813 { | 813 { |
| 814 ScrollToOptions scrollToOptions; | 814 ScrollToOptions scrollToOptions; |
| 815 scrollToOptions.setLeft(x); | 815 scrollToOptions.setLeft(x); |
| 816 scrollToOptions.setTop(y); | 816 scrollToOptions.setTop(y); |
| 817 scrollBy(scrollToOptions); | 817 scrollBy(scrollToOptions); |
| 818 } | 818 } |
| 819 | 819 |
| 820 void Element::scrollBy(const ScrollToOptions& scrollToOptions) | 820 void Element::scrollBy(const ScrollToOptions& scrollToOptions) |
| 821 { | 821 { |
| 822 // FIXME: This should be removed once scroll updates are processed only afte
r | 822 // FIXME: This should be removed once scroll updates are processed only afte
r |
| 823 // the compositing update. See http://crbug.com/420741. | 823 // the compositing update. See http://crbug.com/420741. |
| 824 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 824 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 825 | 825 |
| 826 if (document().scrollingElement() == this) { | 826 if (document().scrollingElement() == this) { |
| 827 scrollFrameBy(scrollToOptions); | 827 scrollFrameBy(scrollToOptions); |
| 828 } else { | 828 } else { |
| 829 scrollLayoutBoxBy(scrollToOptions); | 829 scrollLayoutBoxBy(scrollToOptions); |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 | 832 |
| 833 void Element::scrollTo(double x, double y) | 833 void Element::scrollTo(double x, double y) |
| 834 { | 834 { |
| 835 ScrollToOptions scrollToOptions; | 835 ScrollToOptions scrollToOptions; |
| 836 scrollToOptions.setLeft(x); | 836 scrollToOptions.setLeft(x); |
| 837 scrollToOptions.setTop(y); | 837 scrollToOptions.setTop(y); |
| 838 scrollTo(scrollToOptions); | 838 scrollTo(scrollToOptions); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void Element::scrollTo(const ScrollToOptions& scrollToOptions) | 841 void Element::scrollTo(const ScrollToOptions& scrollToOptions) |
| 842 { | 842 { |
| 843 // FIXME: This should be removed once scroll updates are processed only afte
r | 843 // FIXME: This should be removed once scroll updates are processed only afte
r |
| 844 // the compositing update. See http://crbug.com/420741. | 844 // the compositing update. See http://crbug.com/420741. |
| 845 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 845 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 846 | 846 |
| 847 if (document().scrollingElement() == this) { | 847 if (document().scrollingElement() == this) { |
| 848 scrollFrameTo(scrollToOptions); | 848 scrollFrameTo(scrollToOptions); |
| 849 } else { | 849 } else { |
| 850 scrollLayoutBoxTo(scrollToOptions); | 850 scrollLayoutBoxTo(scrollToOptions); |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 | 853 |
| 854 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) | 854 void Element::scrollLayoutBoxBy(const ScrollToOptions& scrollToOptions) |
| 855 { | 855 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 { | 956 { |
| 957 if (!hasRareData()) | 957 if (!hasRareData()) |
| 958 return CompositorMutableProperty::kNone; | 958 return CompositorMutableProperty::kNone; |
| 959 if (CompositorProxiedPropertySet* set = elementRareData()->proxiedPropertyCo
unts()) | 959 if (CompositorProxiedPropertySet* set = elementRareData()->proxiedPropertyCo
unts()) |
| 960 return set->proxiedProperties(); | 960 return set->proxiedProperties(); |
| 961 return CompositorMutableProperty::kNone; | 961 return CompositorMutableProperty::kNone; |
| 962 } | 962 } |
| 963 | 963 |
| 964 bool Element::hasNonEmptyLayoutSize() const | 964 bool Element::hasNonEmptyLayoutSize() const |
| 965 { | 965 { |
| 966 document().updateLayoutIgnorePendingStylesheets(); | 966 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 967 | 967 |
| 968 if (LayoutBoxModelObject* box = layoutBoxModelObject()) | 968 if (LayoutBoxModelObject* box = layoutBoxModelObject()) |
| 969 return box->hasNonEmptyLayoutSize(); | 969 return box->hasNonEmptyLayoutSize(); |
| 970 return false; | 970 return false; |
| 971 } | 971 } |
| 972 | 972 |
| 973 IntRect Element::boundsInViewport() const | 973 IntRect Element::boundsInViewport() const |
| 974 { | 974 { |
| 975 document().updateLayoutIgnorePendingStylesheets(); | 975 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 976 | 976 |
| 977 FrameView* view = document().view(); | 977 FrameView* view = document().view(); |
| 978 if (!view) | 978 if (!view) |
| 979 return IntRect(); | 979 return IntRect(); |
| 980 | 980 |
| 981 Vector<FloatQuad> quads; | 981 Vector<FloatQuad> quads; |
| 982 if (isSVGElement() && layoutObject()) { | 982 if (isSVGElement() && layoutObject()) { |
| 983 // Get the bounding rectangle from the SVG model. | 983 // Get the bounding rectangle from the SVG model. |
| 984 if (toSVGElement(this)->isSVGGraphicsElement()) | 984 if (toSVGElement(this)->isSVGGraphicsElement()) |
| 985 quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->obj
ectBoundingBox())); | 985 quads.append(layoutObject()->localToAbsoluteQuad(layoutObject()->obj
ectBoundingBox())); |
| 986 } else { | 986 } else { |
| 987 // Get the bounding rectangle from the box model. | 987 // Get the bounding rectangle from the box model. |
| 988 if (layoutBoxModelObject()) | 988 if (layoutBoxModelObject()) |
| 989 layoutBoxModelObject()->absoluteQuads(quads); | 989 layoutBoxModelObject()->absoluteQuads(quads); |
| 990 } | 990 } |
| 991 | 991 |
| 992 if (quads.isEmpty()) | 992 if (quads.isEmpty()) |
| 993 return IntRect(); | 993 return IntRect(); |
| 994 | 994 |
| 995 IntRect result = quads[0].enclosingBoundingBox(); | 995 IntRect result = quads[0].enclosingBoundingBox(); |
| 996 for (size_t i = 1; i < quads.size(); ++i) | 996 for (size_t i = 1; i < quads.size(); ++i) |
| 997 result.unite(quads[i].enclosingBoundingBox()); | 997 result.unite(quads[i].enclosingBoundingBox()); |
| 998 | 998 |
| 999 return view->contentsToViewport(result); | 999 return view->contentsToViewport(result); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 ClientRectList* Element::getClientRects() | 1002 ClientRectList* Element::getClientRects() |
| 1003 { | 1003 { |
| 1004 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1004 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1005 | 1005 |
| 1006 LayoutObject* elementLayoutObject = layoutObject(); | 1006 LayoutObject* elementLayoutObject = layoutObject(); |
| 1007 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) | 1007 if (!elementLayoutObject || (!elementLayoutObject->isBoxModelObject() && !el
ementLayoutObject->isBR())) |
| 1008 return ClientRectList::create(); | 1008 return ClientRectList::create(); |
| 1009 | 1009 |
| 1010 // FIXME: Handle SVG elements. | 1010 // FIXME: Handle SVG elements. |
| 1011 // FIXME: Handle table/inline-table with a caption. | 1011 // FIXME: Handle table/inline-table with a caption. |
| 1012 | 1012 |
| 1013 Vector<FloatQuad> quads; | 1013 Vector<FloatQuad> quads; |
| 1014 elementLayoutObject->absoluteQuads(quads); | 1014 elementLayoutObject->absoluteQuads(quads); |
| 1015 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); | 1015 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementLayoutObj
ect); |
| 1016 return ClientRectList::create(quads); | 1016 return ClientRectList::create(quads); |
| 1017 } | 1017 } |
| 1018 | 1018 |
| 1019 ClientRect* Element::getBoundingClientRect() | 1019 ClientRect* Element::getBoundingClientRect() |
| 1020 { | 1020 { |
| 1021 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1021 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1022 | 1022 |
| 1023 Vector<FloatQuad> quads; | 1023 Vector<FloatQuad> quads; |
| 1024 LayoutObject* elementLayoutObject = layoutObject(); | 1024 LayoutObject* elementLayoutObject = layoutObject(); |
| 1025 if (elementLayoutObject) { | 1025 if (elementLayoutObject) { |
| 1026 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { | 1026 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { |
| 1027 // Get the bounding rectangle from the SVG model. | 1027 // Get the bounding rectangle from the SVG model. |
| 1028 if (toSVGElement(this)->isSVGGraphicsElement()) | 1028 if (toSVGElement(this)->isSVGGraphicsElement()) |
| 1029 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); | 1029 quads.append(elementLayoutObject->localToAbsoluteQuad(elementLay
outObject->objectBoundingBox())); |
| 1030 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { | 1030 } else if (elementLayoutObject->isBoxModelObject() || elementLayoutObjec
t->isBR()) { |
| 1031 elementLayoutObject->absoluteQuads(quads); | 1031 elementLayoutObject->absoluteQuads(quads); |
| 1032 } | 1032 } |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 if (quads.isEmpty()) | 1035 if (quads.isEmpty()) |
| 1036 return ClientRect::create(); | 1036 return ClientRect::create(); |
| 1037 | 1037 |
| 1038 FloatRect result = quads[0].boundingBox(); | 1038 FloatRect result = quads[0].boundingBox(); |
| 1039 for (size_t i = 1; i < quads.size(); ++i) | 1039 for (size_t i = 1; i < quads.size(); ++i) |
| 1040 result.unite(quads[i].boundingBox()); | 1040 result.unite(quads[i].boundingBox()); |
| 1041 | 1041 |
| 1042 DCHECK(elementLayoutObject); | 1042 DCHECK(elementLayoutObject); |
| 1043 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); | 1043 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementLayoutObj
ect); |
| 1044 return ClientRect::create(result); | 1044 return ClientRect::create(result); |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 const AtomicString& Element::computedRole() | 1047 const AtomicString& Element::computedRole() |
| 1048 { | 1048 { |
| 1049 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1049 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1050 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); | 1050 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); |
| 1051 return cache->get()->computedRoleForNode(this); | 1051 return cache->get()->computedRoleForNode(this); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 String Element::computedName() | 1054 String Element::computedName() |
| 1055 { | 1055 { |
| 1056 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 1056 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 1057 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); | 1057 OwnPtr<ScopedAXObjectCache> cache = ScopedAXObjectCache::create(document()); |
| 1058 return cache->get()->computedNameForNode(this); | 1058 return cache->get()->computedNameForNode(this); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 const AtomicString& Element::getAttribute(const AtomicString& localName) const | 1061 const AtomicString& Element::getAttribute(const AtomicString& localName) const |
| 1062 { | 1062 { |
| 1063 if (!elementData()) | 1063 if (!elementData()) |
| 1064 return nullAtom; | 1064 return nullAtom; |
| 1065 synchronizeAttribute(localName); | 1065 synchronizeAttribute(localName); |
| 1066 if (const Attribute* attribute = elementData()->attributes().find(localName,
shouldIgnoreAttributeCase())) | 1066 if (const Attribute* attribute = elementData()->attributes().find(localName,
shouldIgnoreAttributeCase())) |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 { | 2370 { |
| 2371 if (!inShadowIncludingDocument()) | 2371 if (!inShadowIncludingDocument()) |
| 2372 return; | 2372 return; |
| 2373 | 2373 |
| 2374 if (document().focusedElement() == this) | 2374 if (document().focusedElement() == this) |
| 2375 return; | 2375 return; |
| 2376 | 2376 |
| 2377 if (!document().isActive()) | 2377 if (!document().isActive()) |
| 2378 return; | 2378 return; |
| 2379 | 2379 |
| 2380 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 2380 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 2381 if (!isFocusable()) | 2381 if (!isFocusable()) |
| 2382 return; | 2382 return; |
| 2383 | 2383 |
| 2384 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { | 2384 if (authorShadowRoot() && authorShadowRoot()->delegatesFocus()) { |
| 2385 if (isShadowIncludingInclusiveAncestorOf(document().focusedElement())) | 2385 if (isShadowIncludingInclusiveAncestorOf(document().focusedElement())) |
| 2386 return; | 2386 return; |
| 2387 | 2387 |
| 2388 // Slide the focus to its inner node. | 2388 // Slide the focus to its inner node. |
| 2389 Element* found = document().page()->focusController().findFocusableEleme
ntInShadowHost(*this); | 2389 Element* found = document().page()->focusController().findFocusableEleme
ntInShadowHost(*this); |
| 2390 if (found && isShadowIncludingInclusiveAncestorOf(found)) { | 2390 if (found && isShadowIncludingInclusiveAncestorOf(found)) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 else if (document().frame()->eventHandler().getPointerEventType(pointerI
d) == WebPointerProperties::PointerType::Touch) | 2689 else if (document().frame()->eventHandler().getPointerEventType(pointerI
d) == WebPointerProperties::PointerType::Touch) |
| 2690 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId
"); | 2690 exceptionState.throwDOMException(InvalidPointerId, "InvalidPointerId
"); |
| 2691 else | 2691 else |
| 2692 document().frame()->eventHandler().releasePointerCapture(pointerId,
this); | 2692 document().frame()->eventHandler().releasePointerCapture(pointerId,
this); |
| 2693 } | 2693 } |
| 2694 } | 2694 } |
| 2695 | 2695 |
| 2696 String Element::innerText() | 2696 String Element::innerText() |
| 2697 { | 2697 { |
| 2698 // We need to update layout, since plainText uses line boxes in the layout t
ree. | 2698 // We need to update layout, since plainText uses line boxes in the layout t
ree. |
| 2699 document().updateLayoutIgnorePendingStylesheetsForNode(this); | 2699 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
| 2700 | 2700 |
| 2701 if (!layoutObject()) | 2701 if (!layoutObject()) |
| 2702 return textContent(true); | 2702 return textContent(true); |
| 2703 | 2703 |
| 2704 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne
rText); | 2704 return plainText(EphemeralRange::rangeOfContents(*this), TextIteratorForInne
rText); |
| 2705 } | 2705 } |
| 2706 | 2706 |
| 2707 String Element::outerText() | 2707 String Element::outerText() |
| 2708 { | 2708 { |
| 2709 // Getting outerText is the same as getting innerText, only | 2709 // Getting outerText is the same as getting innerText, only |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3707 | 3707 |
| 3708 DEFINE_TRACE_WRAPPERS(Element) | 3708 DEFINE_TRACE_WRAPPERS(Element) |
| 3709 { | 3709 { |
| 3710 if (hasRareData()) { | 3710 if (hasRareData()) { |
| 3711 visitor->traceWrappers(elementRareData()); | 3711 visitor->traceWrappers(elementRareData()); |
| 3712 } | 3712 } |
| 3713 ContainerNode::traceWrappers(visitor); | 3713 ContainerNode::traceWrappers(visitor); |
| 3714 } | 3714 } |
| 3715 | 3715 |
| 3716 } // namespace blink | 3716 } // namespace blink |
| OLD | NEW |