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. | 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (const Attribute* attribute = elementData()->attributes().find(name)) | 422 if (const Attribute* attribute = elementData()->attributes().find(name)) |
423 return attribute->value(); | 423 return attribute->value(); |
424 return nullAtom; | 424 return nullAtom; |
425 } | 425 } |
426 | 426 |
427 bool Element::shouldIgnoreAttributeCase() const { | 427 bool Element::shouldIgnoreAttributeCase() const { |
428 return isHTMLElement() && document().isHTMLDocument(); | 428 return isHTMLElement() && document().isHTMLDocument(); |
429 } | 429 } |
430 | 430 |
431 void Element::scrollIntoView(bool alignToTop) { | 431 void Element::scrollIntoView(bool alignToTop) { |
432 ensureCompositingInputsClean(); | 432 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
433 | 433 |
434 if (!layoutObject()) | 434 if (!layoutObject()) |
435 return; | 435 return; |
436 | 436 |
437 bool makeVisibleInVisualViewport = | 437 bool makeVisibleInVisualViewport = |
438 !document().page()->settings().getInertVisualViewport(); | 438 !document().page()->settings().getInertVisualViewport(); |
439 | 439 |
440 LayoutRect bounds = boundingBox(); | 440 LayoutRect bounds = boundingBox(); |
441 // Align to the top / bottom and to the closest edge. | 441 // Align to the top / bottom and to the closest edge. |
442 if (alignToTop) | 442 if (alignToTop) |
443 layoutObject()->scrollRectToVisible( | 443 layoutObject()->scrollRectToVisible( |
444 bounds, ScrollAlignment::alignToEdgeIfNeeded, | 444 bounds, ScrollAlignment::alignToEdgeIfNeeded, |
445 ScrollAlignment::alignTopAlways, ProgrammaticScroll, | 445 ScrollAlignment::alignTopAlways, ProgrammaticScroll, |
446 makeVisibleInVisualViewport); | 446 makeVisibleInVisualViewport); |
447 else | 447 else |
448 layoutObject()->scrollRectToVisible( | 448 layoutObject()->scrollRectToVisible( |
449 bounds, ScrollAlignment::alignToEdgeIfNeeded, | 449 bounds, ScrollAlignment::alignToEdgeIfNeeded, |
450 ScrollAlignment::alignBottomAlways, ProgrammaticScroll, | 450 ScrollAlignment::alignBottomAlways, ProgrammaticScroll, |
451 makeVisibleInVisualViewport); | 451 makeVisibleInVisualViewport); |
452 | 452 |
453 document().setSequentialFocusNavigationStartingPoint(this); | 453 document().setSequentialFocusNavigationStartingPoint(this); |
454 } | 454 } |
455 | 455 |
456 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) { | 456 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) { |
457 ensureCompositingInputsClean(); | 457 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
458 | 458 |
459 if (!layoutObject()) | 459 if (!layoutObject()) |
460 return; | 460 return; |
461 | 461 |
462 bool makeVisibleInVisualViewport = | 462 bool makeVisibleInVisualViewport = |
463 !document().page()->settings().getInertVisualViewport(); | 463 !document().page()->settings().getInertVisualViewport(); |
464 | 464 |
465 LayoutRect bounds = boundingBox(); | 465 LayoutRect bounds = boundingBox(); |
466 if (centerIfNeeded) | 466 if (centerIfNeeded) |
467 layoutObject()->scrollRectToVisible( | 467 layoutObject()->scrollRectToVisible( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 callback->handleEvent(&scrollState); | 627 callback->handleEvent(&scrollState); |
628 if (callback->nativeScrollBehavior() != | 628 if (callback->nativeScrollBehavior() != |
629 WebNativeScrollBehavior::DisableNativeScroll) | 629 WebNativeScrollBehavior::DisableNativeScroll) |
630 nativeApplyScroll(scrollState); | 630 nativeApplyScroll(scrollState); |
631 if (callback->nativeScrollBehavior() == | 631 if (callback->nativeScrollBehavior() == |
632 WebNativeScrollBehavior::PerformAfterNativeScroll) | 632 WebNativeScrollBehavior::PerformAfterNativeScroll) |
633 callback->handleEvent(&scrollState); | 633 callback->handleEvent(&scrollState); |
634 } | 634 } |
635 | 635 |
636 int Element::offsetLeft() { | 636 int Element::offsetLeft() { |
637 ensureCompositingInputsClean(); | 637 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
638 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 638 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
639 return adjustLayoutUnitForAbsoluteZoom( | 639 return adjustLayoutUnitForAbsoluteZoom( |
640 LayoutUnit(layoutObject->pixelSnappedOffsetLeft(offsetParent())), | 640 LayoutUnit(layoutObject->pixelSnappedOffsetLeft(offsetParent())), |
641 layoutObject->styleRef()) | 641 layoutObject->styleRef()) |
642 .round(); | 642 .round(); |
643 return 0; | 643 return 0; |
644 } | 644 } |
645 | 645 |
646 int Element::offsetTop() { | 646 int Element::offsetTop() { |
647 ensureCompositingInputsClean(); | 647 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
648 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) | 648 if (LayoutBoxModelObject* layoutObject = layoutBoxModelObject()) |
649 return adjustLayoutUnitForAbsoluteZoom( | 649 return adjustLayoutUnitForAbsoluteZoom( |
650 LayoutUnit(layoutObject->pixelSnappedOffsetTop(offsetParent())), | 650 LayoutUnit(layoutObject->pixelSnappedOffsetTop(offsetParent())), |
651 layoutObject->styleRef()) | 651 layoutObject->styleRef()) |
652 .round(); | 652 .round(); |
653 return 0; | 653 return 0; |
654 } | 654 } |
655 | 655 |
656 int Element::offsetWidth() { | 656 int Element::offsetWidth() { |
657 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); | 657 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 IntSize viewportSize = document().page()->frameHost().visualViewport().size(); | 1112 IntSize viewportSize = document().page()->frameHost().visualViewport().size(); |
1113 IntRect rect(0, 0, viewportSize.width(), viewportSize.height()); | 1113 IntRect rect(0, 0, viewportSize.width(), viewportSize.height()); |
1114 // We don't use absoluteBoundingBoxRect() because it can return an IntRect | 1114 // We don't use absoluteBoundingBoxRect() because it can return an IntRect |
1115 // larger the actual size by 1px. crbug.com/470503 | 1115 // larger the actual size by 1px. crbug.com/470503 |
1116 rect.intersect(document().view()->contentsToViewport( | 1116 rect.intersect(document().view()->contentsToViewport( |
1117 roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect()))); | 1117 roundedIntRect(layoutObject()->absoluteBoundingBoxFloatRect()))); |
1118 return rect; | 1118 return rect; |
1119 } | 1119 } |
1120 | 1120 |
1121 void Element::clientQuads(Vector<FloatQuad>& quads) { | 1121 void Element::clientQuads(Vector<FloatQuad>& quads) { |
1122 ensureCompositingInputsClean(); | 1122 document().updateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
1123 | 1123 |
1124 LayoutObject* elementLayoutObject = layoutObject(); | 1124 LayoutObject* elementLayoutObject = layoutObject(); |
1125 if (!elementLayoutObject) | 1125 if (!elementLayoutObject) |
1126 return; | 1126 return; |
1127 | 1127 |
1128 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { | 1128 if (isSVGElement() && !elementLayoutObject->isSVGRoot()) { |
1129 // Get the bounding rectangle from the SVG model. | 1129 // Get the bounding rectangle from the SVG model. |
1130 if (toSVGElement(this)->isSVGGraphicsElement()) | 1130 if (toSVGElement(this)->isSVGGraphicsElement()) |
1131 quads.push_back(elementLayoutObject->localToAbsoluteQuad( | 1131 quads.push_back(elementLayoutObject->localToAbsoluteQuad( |
1132 elementLayoutObject->objectBoundingBox())); | 1132 elementLayoutObject->objectBoundingBox())); |
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4113 if (!activityLogger) | 4113 if (!activityLogger) |
4114 return; | 4114 return; |
4115 Vector<String, 4> argv; | 4115 Vector<String, 4> argv; |
4116 argv.push_back(element); | 4116 argv.push_back(element); |
4117 argv.push_back(params.name.toString()); | 4117 argv.push_back(params.name.toString()); |
4118 argv.push_back(params.oldValue); | 4118 argv.push_back(params.oldValue); |
4119 argv.push_back(params.newValue); | 4119 argv.push_back(params.newValue); |
4120 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); | 4120 activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data()); |
4121 } | 4121 } |
4122 | 4122 |
4123 void Element::ensureCompositingInputsClean() { | |
4124 if (!inActiveDocument()) | |
4125 return; | |
4126 | |
4127 // The call to updateLifecycleToCompositingCleanPlusScrolling| below would | |
4128 // also run layout for us if we omitted this call. However we do not want to | |
4129 // include pending style sheets when doing the layout, hence this call. | |
4130 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
4131 | |
4132 if (FrameView* view = document().view()) | |
4133 view->updateLifecycleToCompositingCleanPlusScrolling(); | |
4134 } | |
4135 | |
4136 DEFINE_TRACE(Element) { | 4123 DEFINE_TRACE(Element) { |
4137 if (hasRareData()) | 4124 if (hasRareData()) |
4138 visitor->trace(elementRareData()); | 4125 visitor->trace(elementRareData()); |
4139 visitor->trace(m_elementData); | 4126 visitor->trace(m_elementData); |
4140 ContainerNode::trace(visitor); | 4127 ContainerNode::trace(visitor); |
4141 } | 4128 } |
4142 | 4129 |
4143 DEFINE_TRACE_WRAPPERS(Element) { | 4130 DEFINE_TRACE_WRAPPERS(Element) { |
4144 if (hasRareData()) { | 4131 if (hasRareData()) { |
4145 visitor->traceWrappers(elementRareData()); | 4132 visitor->traceWrappers(elementRareData()); |
4146 } | 4133 } |
4147 ContainerNode::traceWrappers(visitor); | 4134 ContainerNode::traceWrappers(visitor); |
4148 } | 4135 } |
4149 | 4136 |
4150 } // namespace blink | 4137 } // namespace blink |
OLD | NEW |