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

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: Created 3 years, 8 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 EnsureLifecycleValidForLocationAPIs();
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 EnsureLifecycleValidForLocationAPIs();
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 EnsureLifecycleValidForLocationAPIs();
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 EnsureLifecycleValidForLocationAPIs();
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().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 EnsureLifecycleValidForLocationAPIs();
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 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after
4321 if (!activity_logger) 4321 if (!activity_logger)
4322 return; 4322 return;
4323 Vector<String, 4> argv; 4323 Vector<String, 4> argv;
4324 argv.push_back(element); 4324 argv.push_back(element);
4325 argv.push_back(params.name.ToString()); 4325 argv.push_back(params.name.ToString());
4326 argv.push_back(params.old_value); 4326 argv.push_back(params.old_value);
4327 argv.push_back(params.new_value); 4327 argv.push_back(params.new_value);
4328 activity_logger->LogEvent("blinkSetAttribute", argv.size(), argv.Data()); 4328 activity_logger->LogEvent("blinkSetAttribute", argv.size(), argv.Data());
4329 } 4329 }
4330 4330
4331 void Element::EnsureLifecycleValidForLocationAPIs() {
4332 if (!InActiveDocument())
4333 return;
4334
4335 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
4336
4337 FrameView* view = GetDocument().View();
4338 LayoutObject* element_layout_object = GetLayoutObject();
4339 if (UNLIKELY(view && element_layout_object &&
4340 element_layout_object->EnclosingBoxModelObject() &&
4341 element_layout_object->EnclosingBoxModelObject()
4342 ->IsInStickySubtree())) {
4343 view->UpdateLifecycleToCompositingInputsClean();
chrishtr 2017/04/20 17:40:34 Add a comment explaining why this is needed.
smcgruer 2017/04/26 14:37:06 Done.
4344 }
4345 }
4346
4331 DEFINE_TRACE(Element) { 4347 DEFINE_TRACE(Element) {
4332 if (HasRareData()) 4348 if (HasRareData())
4333 visitor->Trace(GetElementRareData()); 4349 visitor->Trace(GetElementRareData());
4334 visitor->Trace(element_data_); 4350 visitor->Trace(element_data_);
4335 ContainerNode::Trace(visitor); 4351 ContainerNode::Trace(visitor);
4336 } 4352 }
4337 4353
4338 DEFINE_TRACE_WRAPPERS(Element) { 4354 DEFINE_TRACE_WRAPPERS(Element) {
4339 if (HasRareData()) { 4355 if (HasRareData()) {
4340 visitor->TraceWrappers(GetElementRareData()); 4356 visitor->TraceWrappers(GetElementRareData());
4341 } 4357 }
4342 ContainerNode::TraceWrappers(visitor); 4358 ContainerNode::TraceWrappers(visitor);
4343 } 4359 }
4344 4360
4345 } // namespace blink 4361 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698