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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 } | 518 } |
519 | 519 |
520 static double adjustForLocalZoom(LayoutUnit value, RenderObject& renderer) | 520 static double adjustForLocalZoom(LayoutUnit value, RenderObject& renderer) |
521 { | 521 { |
522 float zoomFactor = localZoomForRenderer(renderer); | 522 float zoomFactor = localZoomForRenderer(renderer); |
523 if (zoomFactor == 1) | 523 if (zoomFactor == 1) |
524 return value.toDouble(); | 524 return value.toDouble(); |
525 return value.toDouble() / zoomFactor; | 525 return value.toDouble() / zoomFactor; |
526 } | 526 } |
527 | 527 |
528 double Element::offsetLeft() | 528 int Element::offsetLeft() |
529 { | 529 { |
530 document().updateLayoutIgnorePendingStylesheets(); | 530 document().updateLayoutIgnorePendingStylesheets(); |
531 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 531 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
532 return adjustForLocalZoom(renderer->offsetLeft(), *renderer); | 532 return lroundf(adjustForLocalZoom(renderer->offsetLeft(), *renderer)); |
533 return 0; | 533 return 0; |
534 } | 534 } |
535 | 535 |
536 double Element::offsetTop() | 536 int Element::offsetTop() |
537 { | 537 { |
538 document().updateLayoutIgnorePendingStylesheets(); | 538 document().updateLayoutIgnorePendingStylesheets(); |
539 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 539 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
540 return adjustForLocalZoom(renderer->offsetTop(), *renderer); | 540 return lroundf(adjustForLocalZoom(renderer->pixelSnappedOffsetTop(), *re
nderer)); |
541 return 0; | 541 return 0; |
542 } | 542 } |
543 | 543 |
544 double Element::offsetWidth() | 544 int Element::offsetWidth() |
545 { | 545 { |
546 document().updateLayoutIgnorePendingStylesheets(); | 546 document().updateLayoutIgnorePendingStylesheets(); |
547 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 547 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
548 return adjustLayoutUnitForAbsoluteZoom(renderer->offsetWidth(), *rendere
r).toFloat(); | 548 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetWidth
(), *renderer).round(); |
549 return 0; | 549 return 0; |
550 } | 550 } |
551 | 551 |
552 double Element::offsetHeight() | 552 int Element::offsetHeight() |
553 { | 553 { |
554 document().updateLayoutIgnorePendingStylesheets(); | 554 document().updateLayoutIgnorePendingStylesheets(); |
555 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 555 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
556 return adjustLayoutUnitForAbsoluteZoom(renderer->offsetHeight(), *render
er).toFloat(); | 556 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), *renderer).round(); |
557 return 0; | 557 return 0; |
558 } | 558 } |
559 | 559 |
560 Element* Element::offsetParentForBindings() | 560 Element* Element::offsetParentForBindings() |
561 { | 561 { |
562 Element* element = offsetParent(); | 562 Element* element = offsetParent(); |
563 if (!element || !element->isInShadowTree()) | 563 if (!element || !element->isInShadowTree()) |
564 return element; | 564 return element; |
565 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; | 565 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; |
566 } | 566 } |
567 | 567 |
568 Element* Element::offsetParent() | 568 Element* Element::offsetParent() |
569 { | 569 { |
570 document().updateLayoutIgnorePendingStylesheets(); | 570 document().updateLayoutIgnorePendingStylesheets(); |
571 if (RenderObject* renderer = this->renderer()) | 571 if (RenderObject* renderer = this->renderer()) |
572 return renderer->offsetParent(); | 572 return renderer->offsetParent(); |
573 return 0; | 573 return 0; |
574 } | 574 } |
575 | 575 |
576 double Element::clientLeft() | 576 int Element::clientLeft() |
577 { | 577 { |
578 document().updateLayoutIgnorePendingStylesheets(); | 578 document().updateLayoutIgnorePendingStylesheets(); |
579 | 579 |
580 if (RenderBox* renderer = renderBox()) | 580 if (RenderBox* renderer = renderBox()) |
581 return adjustLayoutUnitForAbsoluteZoom(renderer->clientLeft(), *renderer
); | 581 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft()
), *renderer); |
582 return 0; | 582 return 0; |
583 } | 583 } |
584 | 584 |
585 double Element::clientTop() | 585 int Element::clientTop() |
586 { | 586 { |
587 document().updateLayoutIgnorePendingStylesheets(); | 587 document().updateLayoutIgnorePendingStylesheets(); |
588 | 588 |
589 if (RenderBox* renderer = renderBox()) | 589 if (RenderBox* renderer = renderBox()) |
590 return adjustLayoutUnitForAbsoluteZoom(renderer->clientTop(), *renderer)
; | 590 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientTop())
, *renderer); |
591 return 0; | 591 return 0; |
592 } | 592 } |
593 | 593 |
594 double Element::clientWidth() | 594 int Element::clientWidth() |
595 { | 595 { |
596 document().updateLayoutIgnorePendingStylesheets(); | 596 document().updateLayoutIgnorePendingStylesheets(); |
597 | 597 |
598 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. | 598 // When in strict mode, clientWidth for the document element should return t
he width of the containing frame. |
599 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. | 599 // When in quirks mode, clientWidth for the body element should return the w
idth of the containing frame. |
600 bool inQuirksMode = document().inQuirksMode(); | 600 bool inQuirksMode = document().inQuirksMode(); |
601 if ((!inQuirksMode && document().documentElement() == this) | 601 if ((!inQuirksMode && document().documentElement() == this) |
602 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 602 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
603 if (FrameView* view = document().view()) { | 603 if (FrameView* view = document().view()) { |
604 if (RenderView* renderView = document().renderView()) | 604 if (RenderView* renderView = document().renderView()) |
605 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width(
), *renderView); | 605 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width(
), *renderView); |
606 } | 606 } |
607 } | 607 } |
608 | 608 |
609 if (RenderBox* renderer = renderBox()) | 609 if (RenderBox* renderer = renderBox()) |
610 return adjustLayoutUnitForAbsoluteZoom(renderer->clientWidth(), *rendere
r).toFloat(); | 610 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth
(), *renderer).round(); |
611 return 0; | 611 return 0; |
612 } | 612 } |
613 | 613 |
614 double Element::clientHeight() | 614 int Element::clientHeight() |
615 { | 615 { |
616 document().updateLayoutIgnorePendingStylesheets(); | 616 document().updateLayoutIgnorePendingStylesheets(); |
617 | 617 |
618 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. | 618 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. |
619 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. | 619 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. |
620 bool inQuirksMode = document().inQuirksMode(); | 620 bool inQuirksMode = document().inQuirksMode(); |
621 | 621 |
622 if ((!inQuirksMode && document().documentElement() == this) | 622 if ((!inQuirksMode && document().documentElement() == this) |
623 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 623 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
624 if (FrameView* view = document().view()) { | 624 if (FrameView* view = document().view()) { |
625 if (RenderView* renderView = document().renderView()) | 625 if (RenderView* renderView = document().renderView()) |
626 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height
(), *renderView); | 626 return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height
(), *renderView); |
627 } | 627 } |
628 } | 628 } |
629 | 629 |
630 if (RenderBox* renderer = renderBox()) | 630 if (RenderBox* renderer = renderBox()) |
631 return adjustLayoutUnitForAbsoluteZoom(renderer->clientHeight(), *render
er).toFloat(); | 631 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh
t(), *renderer).round(); |
632 return 0; | 632 return 0; |
633 } | 633 } |
634 | 634 |
635 double Element::scrollLeft() | 635 int Element::scrollLeft() |
636 { | 636 { |
637 document().updateLayoutIgnorePendingStylesheets(); | 637 document().updateLayoutIgnorePendingStylesheets(); |
638 | 638 |
639 if (document().documentElement() != this) { | 639 if (document().documentElement() != this) { |
640 if (RenderBox* rend = renderBox()) | 640 if (RenderBox* rend = renderBox()) |
641 return adjustDoubleForAbsoluteZoom(rend->scrollLeft(), *rend); | 641 return adjustDoubleForAbsoluteZoom(rend->scrollLeft(), *rend); |
642 return 0; | 642 return 0; |
643 } | 643 } |
644 | 644 |
645 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 645 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
646 if (document().inQuirksMode()) | 646 if (document().inQuirksMode()) |
647 return 0; | 647 return 0; |
648 | 648 |
649 if (FrameView* view = document().view()) { | 649 if (FrameView* view = document().view()) { |
650 if (RenderView* renderView = document().renderView()) | 650 if (RenderView* renderView = document().renderView()) |
651 return adjustDoubleForAbsoluteZoom(view->scrollX(), *renderView)
; | 651 return adjustDoubleForAbsoluteZoom(view->scrollX(), *renderView)
; |
652 } | 652 } |
653 } | 653 } |
654 | 654 |
655 return 0; | 655 return 0; |
656 } | 656 } |
657 | 657 |
658 double Element::scrollTop() | 658 int Element::scrollTop() |
659 { | 659 { |
660 document().updateLayoutIgnorePendingStylesheets(); | 660 document().updateLayoutIgnorePendingStylesheets(); |
661 | 661 |
662 if (document().documentElement() != this) { | 662 if (document().documentElement() != this) { |
663 if (RenderBox* rend = renderBox()) | 663 if (RenderBox* rend = renderBox()) |
664 return adjustLayoutUnitForAbsoluteZoom(rend->scrollTop(), *rend); | 664 return adjustLayoutUnitForAbsoluteZoom(rend->scrollTop(), *rend); |
665 return 0; | 665 return 0; |
666 } | 666 } |
667 | 667 |
668 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 668 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
669 if (document().inQuirksMode()) | 669 if (document().inQuirksMode()) |
670 return 0; | 670 return 0; |
671 | 671 |
672 if (FrameView* view = document().view()) { | 672 if (FrameView* view = document().view()) { |
673 if (RenderView* renderView = document().renderView()) | 673 if (RenderView* renderView = document().renderView()) |
674 return adjustDoubleForAbsoluteZoom(view->scrollY(), *renderView)
; | 674 return adjustDoubleForAbsoluteZoom(view->scrollY(), *renderView)
; |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 return 0; | 678 return 0; |
679 } | 679 } |
680 | 680 |
681 void Element::setScrollLeft(double newLeft) | 681 void Element::setScrollLeft(int newLeft) |
682 { | 682 { |
683 document().updateLayoutIgnorePendingStylesheets(); | 683 document().updateLayoutIgnorePendingStylesheets(); |
684 | 684 |
685 if (document().documentElement() != this) { | 685 if (document().documentElement() != this) { |
686 if (RenderBox* rend = renderBox()) | 686 if (RenderBox* rend = renderBox()) |
687 rend->setScrollLeft(roundf(newLeft * rend->style()->effectiveZoom())
); | 687 rend->setScrollLeft(roundf(newLeft * rend->style()->effectiveZoom())
); |
688 return; | 688 return; |
689 } | 689 } |
690 | 690 |
691 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 691 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
(...skipping 25 matching lines...) Expand all Loading... |
717 int position; | 717 int position; |
718 if (!scrollOptionsHorizontal.get("x", position)) { | 718 if (!scrollOptionsHorizontal.get("x", position)) { |
719 exceptionState.throwTypeError("ScrollOptionsHorizontal must include an '
x' member."); | 719 exceptionState.throwTypeError("ScrollOptionsHorizontal must include an '
x' member."); |
720 return; | 720 return; |
721 } | 721 } |
722 | 722 |
723 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. | 723 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. |
724 setScrollLeft(position); | 724 setScrollLeft(position); |
725 } | 725 } |
726 | 726 |
727 void Element::setScrollTop(double newTop) | 727 void Element::setScrollTop(int newTop) |
728 { | 728 { |
729 document().updateLayoutIgnorePendingStylesheets(); | 729 document().updateLayoutIgnorePendingStylesheets(); |
730 | 730 |
731 if (document().documentElement() != this) { | 731 if (document().documentElement() != this) { |
732 if (RenderBox* rend = renderBox()) | 732 if (RenderBox* rend = renderBox()) |
733 rend->setScrollTop(roundf(newTop * rend->style()->effectiveZoom())); | 733 rend->setScrollTop(roundf(newTop * rend->style()->effectiveZoom())); |
734 return; | 734 return; |
735 } | 735 } |
736 | 736 |
737 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { | 737 if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
(...skipping 25 matching lines...) Expand all Loading... |
763 int position; | 763 int position; |
764 if (!scrollOptionsVertical.get("y", position)) { | 764 if (!scrollOptionsVertical.get("y", position)) { |
765 exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y'
member."); | 765 exceptionState.throwTypeError("ScrollOptionsVertical must include a 'y'
member."); |
766 return; | 766 return; |
767 } | 767 } |
768 | 768 |
769 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. | 769 // FIXME: Use scrollBehavior to decide whether to scroll smoothly or instant
ly. |
770 setScrollTop(position); | 770 setScrollTop(position); |
771 } | 771 } |
772 | 772 |
773 double Element::scrollWidth() | 773 int Element::scrollWidth() |
774 { | 774 { |
775 document().updateLayoutIgnorePendingStylesheets(); | 775 document().updateLayoutIgnorePendingStylesheets(); |
776 if (RenderBox* rend = renderBox()) | 776 if (RenderBox* rend = renderBox()) |
777 return adjustLayoutUnitForAbsoluteZoom(rend->scrollWidth(), *rend).toDou
ble(); | 777 return adjustLayoutUnitForAbsoluteZoom(rend->scrollWidth(), *rend).toDou
ble(); |
778 return 0; | 778 return 0; |
779 } | 779 } |
780 | 780 |
781 double Element::scrollHeight() | 781 int Element::scrollHeight() |
782 { | 782 { |
783 document().updateLayoutIgnorePendingStylesheets(); | 783 document().updateLayoutIgnorePendingStylesheets(); |
784 if (RenderBox* rend = renderBox()) | 784 if (RenderBox* rend = renderBox()) |
785 return adjustLayoutUnitForAbsoluteZoom(rend->scrollHeight(), *rend).toDo
uble(); | 785 return adjustLayoutUnitForAbsoluteZoom(rend->scrollHeight(), *rend).toDo
uble(); |
786 return 0; | 786 return 0; |
787 } | 787 } |
788 | 788 |
789 IntRect Element::boundsInRootViewSpace() | 789 IntRect Element::boundsInRootViewSpace() |
790 { | 790 { |
791 document().updateLayoutIgnorePendingStylesheets(); | 791 document().updateLayoutIgnorePendingStylesheets(); |
(...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3316 | 3316 |
3317 void Element::trace(Visitor* visitor) | 3317 void Element::trace(Visitor* visitor) |
3318 { | 3318 { |
3319 if (hasRareData()) | 3319 if (hasRareData()) |
3320 visitor->trace(elementRareData()); | 3320 visitor->trace(elementRareData()); |
3321 | 3321 |
3322 ContainerNode::trace(visitor); | 3322 ContainerNode::trace(visitor); |
3323 } | 3323 } |
3324 | 3324 |
3325 } // namespace WebCore | 3325 } // namespace WebCore |
OLD | NEW |