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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 void Element::scrollByLines(int lines) | 521 void Element::scrollByLines(int lines) |
522 { | 522 { |
523 scrollByUnits(lines, ScrollByLine); | 523 scrollByUnits(lines, ScrollByLine); |
524 } | 524 } |
525 | 525 |
526 void Element::scrollByPages(int pages) | 526 void Element::scrollByPages(int pages) |
527 { | 527 { |
528 scrollByUnits(pages, ScrollByPage); | 528 scrollByUnits(pages, ScrollByPage); |
529 } | 529 } |
530 | 530 |
531 static float localZoomForRenderer(RenderObject* renderer) | 531 static float localZoomForRenderer(RenderObject& renderer) |
532 { | 532 { |
533 // FIXME: This does the wrong thing if two opposing zooms are in effect and
canceled each | 533 // FIXME: This does the wrong thing if two opposing zooms are in effect and
canceled each |
534 // other out, but the alternative is that we'd have to crawl up the whole re
nder tree every | 534 // other out, but the alternative is that we'd have to crawl up the whole re
nder tree every |
535 // time (or store an additional bit in the RenderStyle to indicate that a zo
om was specified). | 535 // time (or store an additional bit in the RenderStyle to indicate that a zo
om was specified). |
536 float zoomFactor = 1; | 536 float zoomFactor = 1; |
537 if (renderer->style()->effectiveZoom() != 1) { | 537 if (renderer.style()->effectiveZoom() != 1) { |
538 // Need to find the nearest enclosing RenderObject that set up | 538 // Need to find the nearest enclosing RenderObject that set up |
539 // a differing zoom, and then we divide our result by it to eliminate th
e zoom. | 539 // a differing zoom, and then we divide our result by it to eliminate th
e zoom. |
540 RenderObject* prev = renderer; | 540 RenderObject* prev = &renderer; |
541 for (RenderObject* curr = prev->parent(); curr; curr = curr->parent()) { | 541 for (RenderObject* curr = prev->parent(); curr; curr = curr->parent()) { |
542 if (curr->style()->effectiveZoom() != prev->style()->effectiveZoom()
) { | 542 if (curr->style()->effectiveZoom() != prev->style()->effectiveZoom()
) { |
543 zoomFactor = prev->style()->zoom(); | 543 zoomFactor = prev->style()->zoom(); |
544 break; | 544 break; |
545 } | 545 } |
546 prev = curr; | 546 prev = curr; |
547 } | 547 } |
548 if (prev->isRenderView()) | 548 if (prev->isRenderView()) |
549 zoomFactor = prev->style()->zoom(); | 549 zoomFactor = prev->style()->zoom(); |
550 } | 550 } |
551 return zoomFactor; | 551 return zoomFactor; |
552 } | 552 } |
553 | 553 |
554 static int adjustForLocalZoom(LayoutUnit value, RenderObject* renderer) | 554 static int adjustForLocalZoom(LayoutUnit value, RenderObject& renderer) |
555 { | 555 { |
556 float zoomFactor = localZoomForRenderer(renderer); | 556 float zoomFactor = localZoomForRenderer(renderer); |
557 if (zoomFactor == 1) | 557 if (zoomFactor == 1) |
558 return value; | 558 return value; |
559 return lroundf(value / zoomFactor); | 559 return lroundf(value / zoomFactor); |
560 } | 560 } |
561 | 561 |
562 int Element::offsetLeft() | 562 int Element::offsetLeft() |
563 { | 563 { |
564 document().partialUpdateLayoutIgnorePendingStylesheets(this); | 564 document().partialUpdateLayoutIgnorePendingStylesheets(this); |
565 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 565 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
566 return adjustForLocalZoom(renderer->pixelSnappedOffsetLeft(), renderer); | 566 return adjustForLocalZoom(renderer->pixelSnappedOffsetLeft(), *renderer)
; |
567 return 0; | 567 return 0; |
568 } | 568 } |
569 | 569 |
570 int Element::offsetTop() | 570 int Element::offsetTop() |
571 { | 571 { |
572 document().partialUpdateLayoutIgnorePendingStylesheets(this); | 572 document().partialUpdateLayoutIgnorePendingStylesheets(this); |
573 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 573 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
574 return adjustForLocalZoom(renderer->pixelSnappedOffsetTop(), renderer); | 574 return adjustForLocalZoom(renderer->pixelSnappedOffsetTop(), *renderer); |
575 return 0; | 575 return 0; |
576 } | 576 } |
577 | 577 |
578 int Element::offsetWidth() | 578 int Element::offsetWidth() |
579 { | 579 { |
580 document().updateStyleForNodeIfNeeded(this); | 580 document().updateStyleForNodeIfNeeded(this); |
581 | 581 |
582 if (RenderBox* renderer = renderBox()) { | 582 if (RenderBox* renderer = renderBox()) { |
583 if (renderer->canDetermineWidthWithoutLayout()) | 583 if (renderer->canDetermineWidthWithoutLayout()) |
584 return adjustLayoutUnitForAbsoluteZoom(renderer->fixedOffsetWidth(),
renderer).round(); | 584 return adjustLayoutUnitForAbsoluteZoom(renderer->fixedOffsetWidth(),
*renderer).round(); |
585 } | 585 } |
586 | 586 |
587 document().partialUpdateLayoutIgnorePendingStylesheets(this); | 587 document().partialUpdateLayoutIgnorePendingStylesheets(this); |
588 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 588 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
589 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetWidth
(), renderer).round(); | 589 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetWidth
(), *renderer).round(); |
590 return 0; | 590 return 0; |
591 } | 591 } |
592 | 592 |
593 int Element::offsetHeight() | 593 int Element::offsetHeight() |
594 { | 594 { |
595 document().partialUpdateLayoutIgnorePendingStylesheets(this); | 595 document().partialUpdateLayoutIgnorePendingStylesheets(this); |
596 if (RenderBoxModelObject* renderer = renderBoxModelObject()) | 596 if (RenderBoxModelObject* renderer = renderBoxModelObject()) |
597 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), renderer).round(); | 597 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedOffsetHeigh
t(), *renderer).round(); |
598 return 0; | 598 return 0; |
599 } | 599 } |
600 | 600 |
601 Element* Element::bindingsOffsetParent() | 601 Element* Element::bindingsOffsetParent() |
602 { | 602 { |
603 Element* element = offsetParent(); | 603 Element* element = offsetParent(); |
604 if (!element || !element->isInShadowTree()) | 604 if (!element || !element->isInShadowTree()) |
605 return element; | 605 return element; |
606 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; | 606 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
0; |
607 } | 607 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 bool inQuirksMode = document().inQuirksMode(); | 641 bool inQuirksMode = document().inQuirksMode(); |
642 if ((!inQuirksMode && document().documentElement() == this) | 642 if ((!inQuirksMode && document().documentElement() == this) |
643 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 643 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
644 if (FrameView* view = document().view()) { | 644 if (FrameView* view = document().view()) { |
645 if (RenderView* renderView = document().renderView()) | 645 if (RenderView* renderView = document().renderView()) |
646 return adjustForAbsoluteZoom(view->layoutSize().width(), renderV
iew); | 646 return adjustForAbsoluteZoom(view->layoutSize().width(), renderV
iew); |
647 } | 647 } |
648 } | 648 } |
649 | 649 |
650 if (RenderBox* renderer = renderBox()) | 650 if (RenderBox* renderer = renderBox()) |
651 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth
(), renderer).round(); | 651 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientWidth
(), *renderer).round(); |
652 return 0; | 652 return 0; |
653 } | 653 } |
654 | 654 |
655 int Element::clientHeight() | 655 int Element::clientHeight() |
656 { | 656 { |
657 document().updateLayoutIgnorePendingStylesheets(); | 657 document().updateLayoutIgnorePendingStylesheets(); |
658 | 658 |
659 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. | 659 // When in strict mode, clientHeight for the document element should return
the height of the containing frame. |
660 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. | 660 // When in quirks mode, clientHeight for the body element should return the
height of the containing frame. |
661 bool inQuirksMode = document().inQuirksMode(); | 661 bool inQuirksMode = document().inQuirksMode(); |
662 | 662 |
663 if ((!inQuirksMode && document().documentElement() == this) | 663 if ((!inQuirksMode && document().documentElement() == this) |
664 || (inQuirksMode && isHTMLElement() && document().body() == this)) { | 664 || (inQuirksMode && isHTMLElement() && document().body() == this)) { |
665 if (FrameView* view = document().view()) { | 665 if (FrameView* view = document().view()) { |
666 if (RenderView* renderView = document().renderView()) | 666 if (RenderView* renderView = document().renderView()) |
667 return adjustForAbsoluteZoom(view->layoutSize().height(), render
View); | 667 return adjustForAbsoluteZoom(view->layoutSize().height(), render
View); |
668 } | 668 } |
669 } | 669 } |
670 | 670 |
671 if (RenderBox* renderer = renderBox()) | 671 if (RenderBox* renderer = renderBox()) |
672 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh
t(), renderer).round(); | 672 return adjustLayoutUnitForAbsoluteZoom(renderer->pixelSnappedClientHeigh
t(), *renderer).round(); |
673 return 0; | 673 return 0; |
674 } | 674 } |
675 | 675 |
676 int Element::scrollLeft() | 676 int Element::scrollLeft() |
677 { | 677 { |
678 document().updateLayoutIgnorePendingStylesheets(); | 678 document().updateLayoutIgnorePendingStylesheets(); |
679 | 679 |
680 if (document().documentElement() == this) { | 680 if (document().documentElement() == this) { |
681 if (document().inQuirksMode()) | 681 if (document().inQuirksMode()) |
682 return 0; | 682 return 0; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 821 |
822 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); | 822 RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject(); |
823 if (!renderBoxModelObject) | 823 if (!renderBoxModelObject) |
824 return ClientRectList::create(); | 824 return ClientRectList::create(); |
825 | 825 |
826 // FIXME: Handle SVG elements. | 826 // FIXME: Handle SVG elements. |
827 // FIXME: Handle table/inline-table with a caption. | 827 // FIXME: Handle table/inline-table with a caption. |
828 | 828 |
829 Vector<FloatQuad> quads; | 829 Vector<FloatQuad> quads; |
830 renderBoxModelObject->absoluteQuads(quads); | 830 renderBoxModelObject->absoluteQuads(quads); |
831 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, renderBoxModelObj
ect); | 831 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *renderBoxModelOb
ject); |
832 return ClientRectList::create(quads); | 832 return ClientRectList::create(quads); |
833 } | 833 } |
834 | 834 |
835 PassRefPtr<ClientRect> Element::getBoundingClientRect() | 835 PassRefPtr<ClientRect> Element::getBoundingClientRect() |
836 { | 836 { |
837 document().updateLayoutIgnorePendingStylesheets(); | 837 document().updateLayoutIgnorePendingStylesheets(); |
838 | 838 |
839 Vector<FloatQuad> quads; | 839 Vector<FloatQuad> quads; |
840 if (isSVGElement() && renderer() && !renderer()->isSVGRoot()) { | 840 if (isSVGElement() && renderer() && !renderer()->isSVGRoot()) { |
841 // Get the bounding rectangle from the SVG model. | 841 // Get the bounding rectangle from the SVG model. |
842 SVGElement* svgElement = toSVGElement(this); | 842 SVGElement* svgElement = toSVGElement(this); |
843 FloatRect localRect; | 843 FloatRect localRect; |
844 if (svgElement->getBoundingBox(localRect)) | 844 if (svgElement->getBoundingBox(localRect)) |
845 quads.append(renderer()->localToAbsoluteQuad(localRect)); | 845 quads.append(renderer()->localToAbsoluteQuad(localRect)); |
846 } else { | 846 } else { |
847 // Get the bounding rectangle from the box model. | 847 // Get the bounding rectangle from the box model. |
848 if (renderBoxModelObject()) | 848 if (renderBoxModelObject()) |
849 renderBoxModelObject()->absoluteQuads(quads); | 849 renderBoxModelObject()->absoluteQuads(quads); |
850 } | 850 } |
851 | 851 |
852 if (quads.isEmpty()) | 852 if (quads.isEmpty()) |
853 return ClientRect::create(); | 853 return ClientRect::create(); |
854 | 854 |
855 FloatRect result = quads[0].boundingBox(); | 855 FloatRect result = quads[0].boundingBox(); |
856 for (size_t i = 1; i < quads.size(); ++i) | 856 for (size_t i = 1; i < quads.size(); ++i) |
857 result.unite(quads[i].boundingBox()); | 857 result.unite(quads[i].boundingBox()); |
858 | 858 |
859 document().adjustFloatRectForScrollAndAbsoluteZoom(result, renderer()); | 859 ASSERT(renderer()); |
| 860 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *renderer()); |
860 return ClientRect::create(result); | 861 return ClientRect::create(result); |
861 } | 862 } |
862 | 863 |
863 IntRect Element::screenRect() const | 864 IntRect Element::screenRect() const |
864 { | 865 { |
865 if (!renderer()) | 866 if (!renderer()) |
866 return IntRect(); | 867 return IntRect(); |
867 // FIXME: this should probably respect transforms | 868 // FIXME: this should probably respect transforms |
868 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe
ctIgnoringTransforms()); | 869 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe
ctIgnoringTransforms()); |
869 } | 870 } |
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3497 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems | 3498 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems |
3498 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 | 3499 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 |
3499 if (hasTagName(optionTag) || hasTagName(optgroupTag)) | 3500 if (hasTagName(optionTag) || hasTagName(optgroupTag)) |
3500 return false; | 3501 return false; |
3501 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3502 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
3502 return false; | 3503 return false; |
3503 return true; | 3504 return true; |
3504 } | 3505 } |
3505 | 3506 |
3506 } // namespace WebCore | 3507 } // namespace WebCore |
OLD | NEW |