Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2825343003: Clean compositing inputs for location APIs for sticky-affected elements. (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 return attribute->Value(); 424 return attribute->Value();
425 return g_null_atom; 425 return g_null_atom;
426 } 426 }
427 427
428 AtomicString Element::LowercaseIfNecessary(const AtomicString& name) const { 428 AtomicString Element::LowercaseIfNecessary(const AtomicString& name) const {
429 return IsHTMLElement() && GetDocument().IsHTMLDocument() ? name.LowerASCII() 429 return IsHTMLElement() && GetDocument().IsHTMLDocument() ? name.LowerASCII()
430 : name; 430 : name;
431 } 431 }
432 432
433 void Element::scrollIntoView(bool align_to_top) { 433 void Element::scrollIntoView(bool align_to_top) {
434 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 434 GetDocument().EnsurePaintLocationDataValidForNode(this);
435 435
436 if (!GetLayoutObject()) 436 if (!GetLayoutObject())
437 return; 437 return;
438 438
439 bool make_visible_in_visual_viewport = 439 bool make_visible_in_visual_viewport =
440 !GetDocument().GetPage()->GetSettings().GetInertVisualViewport(); 440 !GetDocument().GetPage()->GetSettings().GetInertVisualViewport();
441 441
442 LayoutRect bounds = BoundingBox(); 442 LayoutRect bounds = BoundingBox();
443 // Align to the top / bottom and to the closest edge. 443 // Align to the top / bottom and to the closest edge.
444 if (align_to_top) 444 if (align_to_top)
445 GetLayoutObject()->ScrollRectToVisible( 445 GetLayoutObject()->ScrollRectToVisible(
446 bounds, ScrollAlignment::kAlignToEdgeIfNeeded, 446 bounds, ScrollAlignment::kAlignToEdgeIfNeeded,
447 ScrollAlignment::kAlignTopAlways, kProgrammaticScroll, 447 ScrollAlignment::kAlignTopAlways, kProgrammaticScroll,
448 make_visible_in_visual_viewport); 448 make_visible_in_visual_viewport);
449 else 449 else
450 GetLayoutObject()->ScrollRectToVisible( 450 GetLayoutObject()->ScrollRectToVisible(
451 bounds, ScrollAlignment::kAlignToEdgeIfNeeded, 451 bounds, ScrollAlignment::kAlignToEdgeIfNeeded,
452 ScrollAlignment::kAlignBottomAlways, kProgrammaticScroll, 452 ScrollAlignment::kAlignBottomAlways, kProgrammaticScroll,
453 make_visible_in_visual_viewport); 453 make_visible_in_visual_viewport);
454 454
455 GetDocument().SetSequentialFocusNavigationStartingPoint(this); 455 GetDocument().SetSequentialFocusNavigationStartingPoint(this);
456 } 456 }
457 457
458 void Element::scrollIntoViewIfNeeded(bool center_if_needed) { 458 void Element::scrollIntoViewIfNeeded(bool center_if_needed) {
459 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 459 GetDocument().EnsurePaintLocationDataValidForNode(this);
460 460
461 if (!GetLayoutObject()) 461 if (!GetLayoutObject())
462 return; 462 return;
463 463
464 bool make_visible_in_visual_viewport = 464 bool make_visible_in_visual_viewport =
465 !GetDocument().GetPage()->GetSettings().GetInertVisualViewport(); 465 !GetDocument().GetPage()->GetSettings().GetInertVisualViewport();
466 466
467 LayoutRect bounds = BoundingBox(); 467 LayoutRect bounds = BoundingBox();
468 if (center_if_needed) 468 if (center_if_needed)
469 GetLayoutObject()->ScrollRectToVisible( 469 GetLayoutObject()->ScrollRectToVisible(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 callback->handleEvent(&scroll_state); 636 callback->handleEvent(&scroll_state);
637 if (callback->NativeScrollBehavior() != 637 if (callback->NativeScrollBehavior() !=
638 WebNativeScrollBehavior::kDisableNativeScroll) 638 WebNativeScrollBehavior::kDisableNativeScroll)
639 NativeApplyScroll(scroll_state); 639 NativeApplyScroll(scroll_state);
640 if (callback->NativeScrollBehavior() == 640 if (callback->NativeScrollBehavior() ==
641 WebNativeScrollBehavior::kPerformAfterNativeScroll) 641 WebNativeScrollBehavior::kPerformAfterNativeScroll)
642 callback->handleEvent(&scroll_state); 642 callback->handleEvent(&scroll_state);
643 } 643 }
644 644
645 int Element::OffsetLeft() { 645 int Element::OffsetLeft() {
646 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 646 GetDocument().EnsurePaintLocationDataValidForNode(this);
647 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject()) 647 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject())
648 return AdjustLayoutUnitForAbsoluteZoom( 648 return AdjustLayoutUnitForAbsoluteZoom(
649 LayoutUnit( 649 LayoutUnit(
650 layout_object->PixelSnappedOffsetLeft(OffsetParent())), 650 layout_object->PixelSnappedOffsetLeft(OffsetParent())),
651 layout_object->StyleRef()) 651 layout_object->StyleRef())
652 .Round(); 652 .Round();
653 return 0; 653 return 0;
654 } 654 }
655 655
656 int Element::OffsetTop() { 656 int Element::OffsetTop() {
657 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 657 GetDocument().EnsurePaintLocationDataValidForNode(this);
658 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject()) 658 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject())
659 return AdjustLayoutUnitForAbsoluteZoom( 659 return AdjustLayoutUnitForAbsoluteZoom(
660 LayoutUnit(layout_object->PixelSnappedOffsetTop(OffsetParent())), 660 LayoutUnit(layout_object->PixelSnappedOffsetTop(OffsetParent())),
661 layout_object->StyleRef()) 661 layout_object->StyleRef())
662 .Round(); 662 .Round();
663 return 0; 663 return 0;
664 } 664 }
665 665
666 int Element::OffsetWidth() { 666 int Element::OffsetWidth() {
667 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 667 GetDocument().EnsurePaintLocationDataValidForNode(this);
668 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject()) 668 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject())
669 return AdjustLayoutUnitForAbsoluteZoom( 669 return AdjustLayoutUnitForAbsoluteZoom(
670 LayoutUnit( 670 LayoutUnit(
671 layout_object->PixelSnappedOffsetWidth(OffsetParent())), 671 layout_object->PixelSnappedOffsetWidth(OffsetParent())),
672 layout_object->StyleRef()) 672 layout_object->StyleRef())
673 .Round(); 673 .Round();
674 return 0; 674 return 0;
675 } 675 }
676 676
677 int Element::OffsetHeight() { 677 int Element::OffsetHeight() {
678 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 678 GetDocument().EnsurePaintLocationDataValidForNode(this);
679 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject()) 679 if (LayoutBoxModelObject* layout_object = GetLayoutBoxModelObject())
680 return AdjustLayoutUnitForAbsoluteZoom( 680 return AdjustLayoutUnitForAbsoluteZoom(
681 LayoutUnit( 681 LayoutUnit(
682 layout_object->PixelSnappedOffsetHeight(OffsetParent())), 682 layout_object->PixelSnappedOffsetHeight(OffsetParent())),
683 layout_object->StyleRef()) 683 layout_object->StyleRef())
684 .Round(); 684 .Round();
685 return 0; 685 return 0;
686 } 686 }
687 687
688 Element* Element::OffsetParent() { 688 Element* Element::OffsetParent() {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1082
1083 bool Element::HasNonEmptyLayoutSize() const { 1083 bool Element::HasNonEmptyLayoutSize() const {
1084 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 1084 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
1085 1085
1086 if (LayoutBoxModelObject* box = GetLayoutBoxModelObject()) 1086 if (LayoutBoxModelObject* box = GetLayoutBoxModelObject())
1087 return box->HasNonEmptyLayoutSize(); 1087 return box->HasNonEmptyLayoutSize();
1088 return false; 1088 return false;
1089 } 1089 }
1090 1090
1091 IntRect Element::BoundsInViewport() const { 1091 IntRect Element::BoundsInViewport() const {
1092 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 1092 GetDocument().EnsurePaintLocationDataValidForNode(this);
1093 1093
1094 FrameView* view = GetDocument().View(); 1094 FrameView* view = GetDocument().View();
1095 if (!view) 1095 if (!view)
1096 return IntRect(); 1096 return IntRect();
1097 1097
1098 Vector<FloatQuad> quads; 1098 Vector<FloatQuad> quads;
1099 if (IsSVGElement() && GetLayoutObject()) { 1099 if (IsSVGElement() && GetLayoutObject()) {
1100 // Get the bounding rectangle from the SVG model. 1100 // Get the bounding rectangle from the SVG model.
1101 if (ToSVGElement(this)->IsSVGGraphicsElement()) 1101 if (ToSVGElement(this)->IsSVGGraphicsElement())
1102 quads.push_back(GetLayoutObject()->LocalToAbsoluteQuad( 1102 quads.push_back(GetLayoutObject()->LocalToAbsoluteQuad(
(...skipping 22 matching lines...) Expand all
1125 IntSize viewport_size = GetDocument().GetPage()->GetVisualViewport().Size(); 1125 IntSize viewport_size = GetDocument().GetPage()->GetVisualViewport().Size();
1126 IntRect rect(0, 0, viewport_size.Width(), viewport_size.Height()); 1126 IntRect rect(0, 0, viewport_size.Width(), viewport_size.Height());
1127 // We don't use absoluteBoundingBoxRect() because it can return an IntRect 1127 // We don't use absoluteBoundingBoxRect() because it can return an IntRect
1128 // larger the actual size by 1px. crbug.com/470503 1128 // larger the actual size by 1px. crbug.com/470503
1129 rect.Intersect(GetDocument().View()->ContentsToViewport( 1129 rect.Intersect(GetDocument().View()->ContentsToViewport(
1130 RoundedIntRect(GetLayoutObject()->AbsoluteBoundingBoxFloatRect()))); 1130 RoundedIntRect(GetLayoutObject()->AbsoluteBoundingBoxFloatRect())));
1131 return rect; 1131 return rect;
1132 } 1132 }
1133 1133
1134 void Element::ClientQuads(Vector<FloatQuad>& quads) { 1134 void Element::ClientQuads(Vector<FloatQuad>& quads) {
1135 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); 1135 GetDocument().EnsurePaintLocationDataValidForNode(this);
1136 1136
1137 LayoutObject* element_layout_object = GetLayoutObject(); 1137 LayoutObject* element_layout_object = GetLayoutObject();
1138 if (!element_layout_object) 1138 if (!element_layout_object)
1139 return; 1139 return;
1140 1140
1141 if (IsSVGElement() && !element_layout_object->IsSVGRoot()) { 1141 if (IsSVGElement() && !element_layout_object->IsSVGRoot()) {
1142 // Get the bounding rectangle from the SVG model. 1142 // Get the bounding rectangle from the SVG model.
1143 if (ToSVGElement(this)->IsSVGGraphicsElement()) 1143 if (ToSVGElement(this)->IsSVGGraphicsElement())
1144 quads.push_back(element_layout_object->LocalToAbsoluteQuad( 1144 quads.push_back(element_layout_object->LocalToAbsoluteQuad(
1145 element_layout_object->ObjectBoundingBox())); 1145 element_layout_object->ObjectBoundingBox()));
(...skipping 3191 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 } 4337 }
4338 4338
4339 DEFINE_TRACE_WRAPPERS(Element) { 4339 DEFINE_TRACE_WRAPPERS(Element) {
4340 if (HasRareData()) { 4340 if (HasRareData()) {
4341 visitor->TraceWrappers(GetElementRareData()); 4341 visitor->TraceWrappers(GetElementRareData());
4342 } 4342 }
4343 ContainerNode::TraceWrappers(visitor); 4343 ContainerNode::TraceWrappers(visitor);
4344 } 4344 }
4345 4345
4346 } // namespace blink 4346 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentTest.cpp ('k') | third_party/WebKit/Source/core/dom/ElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698