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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return hasRareData() ? elementRareData()->tabIndex() : 0; | 229 return hasRareData() ? elementRareData()->tabIndex() : 0; |
230 } | 230 } |
231 | 231 |
232 bool Element::layoutObjectIsFocusable() const | 232 bool Element::layoutObjectIsFocusable() const |
233 { | 233 { |
234 // Elements in canvas fallback content are not rendered, but they are allowe
d to be | 234 // Elements in canvas fallback content are not rendered, but they are allowe
d to be |
235 // focusable as long as their canvas is displayed and visible. | 235 // focusable as long as their canvas is displayed and visible. |
236 if (isInCanvasSubtree()) { | 236 if (isInCanvasSubtree()) { |
237 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc
estorOrSelf(*this); | 237 const HTMLCanvasElement* canvas = Traversal<HTMLCanvasElement>::firstAnc
estorOrSelf(*this); |
238 ASSERT(canvas); | 238 ASSERT(canvas); |
239 return canvas->renderer() && canvas->renderer()->style()->visibility() =
= VISIBLE; | 239 return canvas->layoutObject() && canvas->layoutObject()->style()->visibi
lity() == VISIBLE; |
240 } | 240 } |
241 | 241 |
242 // FIXME: These asserts should be in Node::isFocusable, but there are some | 242 // FIXME: These asserts should be in Node::isFocusable, but there are some |
243 // callsites like Document::setFocusedElement that would currently fail on | 243 // callsites like Document::setFocusedElement that would currently fail on |
244 // them. See crbug.com/251163 | 244 // them. See crbug.com/251163 |
245 if (!renderer()) { | 245 if (!layoutObject()) { |
246 // We can't just use needsStyleRecalc() because if the node is in a | 246 // We can't just use needsStyleRecalc() because if the node is in a |
247 // display:none tree it might say it needs style recalc but the whole | 247 // display:none tree it might say it needs style recalc but the whole |
248 // document is actually up to date. | 248 // document is actually up to date. |
249 // In addition, style cannot be cleared out for non-active documents, | 249 // In addition, style cannot be cleared out for non-active documents, |
250 // so in that case the childNeedsStyleRecalc check is invalid. | 250 // so in that case the childNeedsStyleRecalc check is invalid. |
251 ASSERT(!document().isActive() || !document().childNeedsStyleRecalc()); | 251 ASSERT(!document().isActive() || !document().childNeedsStyleRecalc()); |
252 } | 252 } |
253 | 253 |
254 // FIXME: Even if we are not visible, we might have a child that is visible. | 254 // FIXME: Even if we are not visible, we might have a child that is visible. |
255 // Hyatt wants to fix that some day with a "has visible content" flag or the
like. | 255 // Hyatt wants to fix that some day with a "has visible content" flag or the
like. |
256 if (!renderer() || renderer()->style()->visibility() != VISIBLE) | 256 if (!layoutObject() || layoutObject()->style()->visibility() != VISIBLE) |
257 return false; | 257 return false; |
258 | 258 |
259 return true; | 259 return true; |
260 } | 260 } |
261 | 261 |
262 PassRefPtrWillBeRawPtr<Node> Element::cloneNode(bool deep) | 262 PassRefPtrWillBeRawPtr<Node> Element::cloneNode(bool deep) |
263 { | 263 { |
264 return deep ? cloneElementWithChildren() : cloneElementWithoutChildren(); | 264 return deep ? cloneElementWithChildren() : cloneElementWithoutChildren(); |
265 } | 265 } |
266 | 266 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 bool Element::shouldIgnoreAttributeCase() const | 450 bool Element::shouldIgnoreAttributeCase() const |
451 { | 451 { |
452 return isHTMLElement() && document().isHTMLDocument(); | 452 return isHTMLElement() && document().isHTMLDocument(); |
453 } | 453 } |
454 | 454 |
455 void Element::scrollIntoView(bool alignToTop) | 455 void Element::scrollIntoView(bool alignToTop) |
456 { | 456 { |
457 document().updateLayoutIgnorePendingStylesheets(); | 457 document().updateLayoutIgnorePendingStylesheets(); |
458 | 458 |
459 if (!renderer()) | 459 if (!layoutObject()) |
460 return; | 460 return; |
461 | 461 |
462 LayoutRect bounds = boundingBox(); | 462 LayoutRect bounds = boundingBox(); |
463 // Align to the top / bottom and to the closest edge. | 463 // Align to the top / bottom and to the closest edge. |
464 if (alignToTop) | 464 if (alignToTop) |
465 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignTopAlways); | 465 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignTopAlways); |
466 else | 466 else |
467 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignBottomAlways); | 467 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignBottomAlways); |
468 } | 468 } |
469 | 469 |
470 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) | 470 void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) |
471 { | 471 { |
472 document().updateLayoutIgnorePendingStylesheets(); | 472 document().updateLayoutIgnorePendingStylesheets(); |
473 | 473 |
474 if (!renderer()) | 474 if (!layoutObject()) |
475 return; | 475 return; |
476 | 476 |
477 LayoutRect bounds = boundingBox(); | 477 LayoutRect bounds = boundingBox(); |
478 if (centerIfNeeded) | 478 if (centerIfNeeded) |
479 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNe
eded, ScrollAlignment::alignCenterIfNeeded); | 479 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenter
IfNeeded, ScrollAlignment::alignCenterIfNeeded); |
480 else | 480 else |
481 renderer()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNe
eded, ScrollAlignment::alignToEdgeIfNeeded); | 481 layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdge
IfNeeded, ScrollAlignment::alignToEdgeIfNeeded); |
482 } | 482 } |
483 | 483 |
484 static float localZoomForRenderer(LayoutObject& renderer) | 484 static float localZoomForRenderer(LayoutObject& renderer) |
485 { | 485 { |
486 // FIXME: This does the wrong thing if two opposing zooms are in effect and
canceled each | 486 // FIXME: This does the wrong thing if two opposing zooms are in effect and
canceled each |
487 // other out, but the alternative is that we'd have to crawl up the whole re
nder tree every | 487 // other out, but the alternative is that we'd have to crawl up the whole re
nder tree every |
488 // time (or store an additional bit in the LayoutStyle to indicate that a zo
om was specified). | 488 // time (or store an additional bit in the LayoutStyle to indicate that a zo
om was specified). |
489 float zoomFactor = 1; | 489 float zoomFactor = 1; |
490 if (renderer.style()->effectiveZoom() != 1) { | 490 if (renderer.style()->effectiveZoom() != 1) { |
491 // Need to find the nearest enclosing LayoutObject that set up | 491 // Need to find the nearest enclosing LayoutObject that set up |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 { | 548 { |
549 Element* element = offsetParent(); | 549 Element* element = offsetParent(); |
550 if (!element || !element->isInShadowTree()) | 550 if (!element || !element->isInShadowTree()) |
551 return element; | 551 return element; |
552 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
nullptr; | 552 return element->containingShadowRoot()->shouldExposeToBindings() ? element :
nullptr; |
553 } | 553 } |
554 | 554 |
555 Element* Element::offsetParent() | 555 Element* Element::offsetParent() |
556 { | 556 { |
557 document().updateLayoutIgnorePendingStylesheets(); | 557 document().updateLayoutIgnorePendingStylesheets(); |
558 if (LayoutObject* renderer = this->renderer()) | 558 if (LayoutObject* renderer = this->layoutObject()) |
559 return renderer->offsetParent(); | 559 return renderer->offsetParent(); |
560 return nullptr; | 560 return nullptr; |
561 } | 561 } |
562 | 562 |
563 int Element::clientLeft() | 563 int Element::clientLeft() |
564 { | 564 { |
565 document().updateLayoutIgnorePendingStylesheets(); | 565 document().updateLayoutIgnorePendingStylesheets(); |
566 | 566 |
567 if (LayoutBox* renderer = layoutBox()) | 567 if (LayoutBox* renderer = layoutBox()) |
568 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft()
), *renderer); | 568 return adjustLayoutUnitForAbsoluteZoom(roundToInt(renderer->clientLeft()
), *renderer); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 | 869 |
870 IntRect Element::boundsInViewportSpace() | 870 IntRect Element::boundsInViewportSpace() |
871 { | 871 { |
872 document().updateLayoutIgnorePendingStylesheets(); | 872 document().updateLayoutIgnorePendingStylesheets(); |
873 | 873 |
874 FrameView* view = document().view(); | 874 FrameView* view = document().view(); |
875 if (!view) | 875 if (!view) |
876 return IntRect(); | 876 return IntRect(); |
877 | 877 |
878 Vector<FloatQuad> quads; | 878 Vector<FloatQuad> quads; |
879 if (isSVGElement() && renderer()) { | 879 if (isSVGElement() && layoutObject()) { |
880 // Get the bounding rectangle from the SVG model. | 880 // Get the bounding rectangle from the SVG model. |
881 SVGElement* svgElement = toSVGElement(this); | 881 SVGElement* svgElement = toSVGElement(this); |
882 FloatRect localRect; | 882 FloatRect localRect; |
883 if (svgElement->getBoundingBox(localRect)) | 883 if (svgElement->getBoundingBox(localRect)) |
884 quads.append(renderer()->localToAbsoluteQuad(localRect)); | 884 quads.append(layoutObject()->localToAbsoluteQuad(localRect)); |
885 } else { | 885 } else { |
886 // Get the bounding rectangle from the box model. | 886 // Get the bounding rectangle from the box model. |
887 if (layoutBoxModelObject()) | 887 if (layoutBoxModelObject()) |
888 layoutBoxModelObject()->absoluteQuads(quads); | 888 layoutBoxModelObject()->absoluteQuads(quads); |
889 } | 889 } |
890 | 890 |
891 if (quads.isEmpty()) | 891 if (quads.isEmpty()) |
892 return IntRect(); | 892 return IntRect(); |
893 | 893 |
894 IntRect result = quads[0].enclosingBoundingBox(); | 894 IntRect result = quads[0].enclosingBoundingBox(); |
895 for (size_t i = 1; i < quads.size(); ++i) | 895 for (size_t i = 1; i < quads.size(); ++i) |
896 result.unite(quads[i].enclosingBoundingBox()); | 896 result.unite(quads[i].enclosingBoundingBox()); |
897 | 897 |
898 result = view->contentsToWindow(result); | 898 result = view->contentsToWindow(result); |
899 | 899 |
900 // FIXME: Cleanup pinch viewport coordinate translations. crbug.com/371902. | 900 // FIXME: Cleanup pinch viewport coordinate translations. crbug.com/371902. |
901 PinchViewport& pinchViewport = document().page()->frameHost().pinchViewport(
); | 901 PinchViewport& pinchViewport = document().page()->frameHost().pinchViewport(
); |
902 result = enclosingIntRect(pinchViewport.mainViewToViewportCSSPixels(result))
; | 902 result = enclosingIntRect(pinchViewport.mainViewToViewportCSSPixels(result))
; |
903 | 903 |
904 return result; | 904 return result; |
905 } | 905 } |
906 | 906 |
907 PassRefPtrWillBeRawPtr<ClientRectList> Element::getClientRects() | 907 PassRefPtrWillBeRawPtr<ClientRectList> Element::getClientRects() |
908 { | 908 { |
909 document().updateLayoutIgnorePendingStylesheets(); | 909 document().updateLayoutIgnorePendingStylesheets(); |
910 | 910 |
911 LayoutObject* elementRenderer = renderer(); | 911 LayoutObject* elementRenderer = layoutObject(); |
912 if (!elementRenderer || (!elementRenderer->isBoxModelObject() && !elementRen
derer->isBR())) | 912 if (!elementRenderer || (!elementRenderer->isBoxModelObject() && !elementRen
derer->isBR())) |
913 return ClientRectList::create(); | 913 return ClientRectList::create(); |
914 | 914 |
915 // FIXME: Handle SVG elements. | 915 // FIXME: Handle SVG elements. |
916 // FIXME: Handle table/inline-table with a caption. | 916 // FIXME: Handle table/inline-table with a caption. |
917 | 917 |
918 Vector<FloatQuad> quads; | 918 Vector<FloatQuad> quads; |
919 elementRenderer->absoluteQuads(quads); | 919 elementRenderer->absoluteQuads(quads); |
920 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementRenderer)
; | 920 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementRenderer)
; |
921 return ClientRectList::create(quads); | 921 return ClientRectList::create(quads); |
922 } | 922 } |
923 | 923 |
924 PassRefPtrWillBeRawPtr<ClientRect> Element::getBoundingClientRect() | 924 PassRefPtrWillBeRawPtr<ClientRect> Element::getBoundingClientRect() |
925 { | 925 { |
926 document().updateLayoutIgnorePendingStylesheets(); | 926 document().updateLayoutIgnorePendingStylesheets(); |
927 | 927 |
928 Vector<FloatQuad> quads; | 928 Vector<FloatQuad> quads; |
929 LayoutObject* elementRenderer = renderer(); | 929 LayoutObject* elementRenderer = layoutObject(); |
930 if (elementRenderer) { | 930 if (elementRenderer) { |
931 if (isSVGElement() && !elementRenderer->isSVGRoot()) { | 931 if (isSVGElement() && !elementRenderer->isSVGRoot()) { |
932 // Get the bounding rectangle from the SVG model. | 932 // Get the bounding rectangle from the SVG model. |
933 SVGElement* svgElement = toSVGElement(this); | 933 SVGElement* svgElement = toSVGElement(this); |
934 FloatRect localRect; | 934 FloatRect localRect; |
935 if (svgElement->getBoundingBox(localRect)) | 935 if (svgElement->getBoundingBox(localRect)) |
936 quads.append(elementRenderer->localToAbsoluteQuad(localRect)); | 936 quads.append(elementRenderer->localToAbsoluteQuad(localRect)); |
937 } else if (elementRenderer->isBoxModelObject() || elementRenderer->isBR(
)) { | 937 } else if (elementRenderer->isBoxModelObject() || elementRenderer->isBR(
)) { |
938 elementRenderer->absoluteQuads(quads); | 938 elementRenderer->absoluteQuads(quads); |
939 } | 939 } |
940 } | 940 } |
941 | 941 |
942 if (quads.isEmpty()) | 942 if (quads.isEmpty()) |
943 return ClientRect::create(); | 943 return ClientRect::create(); |
944 | 944 |
945 FloatRect result = quads[0].boundingBox(); | 945 FloatRect result = quads[0].boundingBox(); |
946 for (size_t i = 1; i < quads.size(); ++i) | 946 for (size_t i = 1; i < quads.size(); ++i) |
947 result.unite(quads[i].boundingBox()); | 947 result.unite(quads[i].boundingBox()); |
948 | 948 |
949 ASSERT(elementRenderer); | 949 ASSERT(elementRenderer); |
950 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementRenderer)
; | 950 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementRenderer)
; |
951 return ClientRect::create(result); | 951 return ClientRect::create(result); |
952 } | 952 } |
953 | 953 |
954 IntRect Element::screenRect() const | 954 IntRect Element::screenRect() const |
955 { | 955 { |
956 if (!renderer()) | 956 if (!layoutObject()) |
957 return IntRect(); | 957 return IntRect(); |
958 // FIXME: this should probably respect transforms | 958 // FIXME: this should probably respect transforms |
959 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe
ctIgnoringTransforms()); | 959 return document().view()->contentsToScreen(layoutObject()->absoluteBoundingB
oxRectIgnoringTransforms()); |
960 } | 960 } |
961 | 961 |
962 const AtomicString& Element::computedRole() | 962 const AtomicString& Element::computedRole() |
963 { | 963 { |
964 document().updateLayoutIgnorePendingStylesheets(); | 964 document().updateLayoutIgnorePendingStylesheets(); |
965 ScopedAXObjectCache cache(document()); | 965 ScopedAXObjectCache cache(document()); |
966 return cache->computedRoleForNode(this); | 966 return cache->computedRoleForNode(this); |
967 } | 967 } |
968 | 968 |
969 String Element::computedName() | 969 String Element::computedName() |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 ContainerNode::attach(context); | 1446 ContainerNode::attach(context); |
1447 | 1447 |
1448 createPseudoElementIfNeeded(AFTER); | 1448 createPseudoElementIfNeeded(AFTER); |
1449 createPseudoElementIfNeeded(BACKDROP); | 1449 createPseudoElementIfNeeded(BACKDROP); |
1450 | 1450 |
1451 // We create the first-letter element after the :before, :after and | 1451 // We create the first-letter element after the :before, :after and |
1452 // children are attached because the first letter text could come | 1452 // children are attached because the first letter text could come |
1453 // from any of them. | 1453 // from any of them. |
1454 createPseudoElementIfNeeded(FIRST_LETTER); | 1454 createPseudoElementIfNeeded(FIRST_LETTER); |
1455 | 1455 |
1456 if (hasRareData() && !renderer()) { | 1456 if (hasRareData() && !layoutObject()) { |
1457 if (ElementAnimations* elementAnimations = elementRareData()->elementAni
mations()) { | 1457 if (ElementAnimations* elementAnimations = elementRareData()->elementAni
mations()) { |
1458 elementAnimations->cssAnimations().cancel(); | 1458 elementAnimations->cssAnimations().cancel(); |
1459 elementAnimations->setAnimationStyleChange(false); | 1459 elementAnimations->setAnimationStyleChange(false); |
1460 } | 1460 } |
1461 } | 1461 } |
1462 } | 1462 } |
1463 | 1463 |
1464 void Element::detach(const AttachContext& context) | 1464 void Element::detach(const AttachContext& context) |
1465 { | 1465 { |
1466 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1466 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
(...skipping 29 matching lines...) Expand all Loading... |
1496 ContainerNode::detach(context); | 1496 ContainerNode::detach(context); |
1497 | 1497 |
1498 ASSERT(needsAttach()); | 1498 ASSERT(needsAttach()); |
1499 if (svgFilterNeedsLayerUpdate()) | 1499 if (svgFilterNeedsLayerUpdate()) |
1500 document().unscheduleSVGFilterLayerUpdateHack(*this); | 1500 document().unscheduleSVGFilterLayerUpdateHack(*this); |
1501 } | 1501 } |
1502 | 1502 |
1503 bool Element::pseudoStyleCacheIsInvalid(const LayoutStyle* currentStyle, LayoutS
tyle* newStyle) | 1503 bool Element::pseudoStyleCacheIsInvalid(const LayoutStyle* currentStyle, LayoutS
tyle* newStyle) |
1504 { | 1504 { |
1505 ASSERT(currentStyle == layoutStyle()); | 1505 ASSERT(currentStyle == layoutStyle()); |
1506 ASSERT(renderer()); | 1506 ASSERT(layoutObject()); |
1507 | 1507 |
1508 if (!currentStyle) | 1508 if (!currentStyle) |
1509 return false; | 1509 return false; |
1510 | 1510 |
1511 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(
); | 1511 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(
); |
1512 if (!pseudoStyleCache) | 1512 if (!pseudoStyleCache) |
1513 return false; | 1513 return false; |
1514 | 1514 |
1515 size_t cacheSize = pseudoStyleCache->size(); | 1515 size_t cacheSize = pseudoStyleCache->size(); |
1516 for (size_t i = 0; i < cacheSize; ++i) { | 1516 for (size_t i = 0; i < cacheSize; ++i) { |
1517 RefPtr<LayoutStyle> newPseudoStyle; | 1517 RefPtr<LayoutStyle> newPseudoStyle; |
1518 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType(); | 1518 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType(); |
1519 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) | 1519 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) |
1520 newPseudoStyle = renderer()->uncachedFirstLineStyle(newStyle); | 1520 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); |
1521 else | 1521 else |
1522 newPseudoStyle = renderer()->getUncachedPseudoStyle(PseudoStyleReque
st(pseudoId), newStyle, newStyle); | 1522 newPseudoStyle = layoutObject()->getUncachedPseudoStyle(PseudoStyleR
equest(pseudoId), newStyle, newStyle); |
1523 if (!newPseudoStyle) | 1523 if (!newPseudoStyle) |
1524 return true; | 1524 return true; |
1525 if (*newPseudoStyle != *pseudoStyleCache->at(i)) { | 1525 if (*newPseudoStyle != *pseudoStyleCache->at(i)) { |
1526 if (pseudoId < FIRST_INTERNAL_PSEUDOID) | 1526 if (pseudoId < FIRST_INTERNAL_PSEUDOID) |
1527 newStyle->setHasPseudoStyle(pseudoId); | 1527 newStyle->setHasPseudoStyle(pseudoId); |
1528 newStyle->addCachedPseudoStyle(newPseudoStyle); | 1528 newStyle->addCachedPseudoStyle(newPseudoStyle); |
1529 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) { | 1529 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) { |
1530 // FIXME: We should do an actual diff to determine whether a rep
aint vs. layout | 1530 // FIXME: We should do an actual diff to determine whether a rep
aint vs. layout |
1531 // is needed, but for now just assume a layout will be required.
The diff code | 1531 // is needed, but for now just assume a layout will be required.
The diff code |
1532 // in LayoutObject::setStyle would need to be factored out so th
at it could be reused. | 1532 // in LayoutObject::setStyle would need to be factored out so th
at it could be reused. |
1533 renderer()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalid
ation(); | 1533 layoutObject()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInv
alidation(); |
1534 } | 1534 } |
1535 return true; | 1535 return true; |
1536 } | 1536 } |
1537 } | 1537 } |
1538 return false; | 1538 return false; |
1539 } | 1539 } |
1540 | 1540 |
1541 PassRefPtr<LayoutStyle> Element::styleForRenderer() | 1541 PassRefPtr<LayoutStyle> Element::styleForRenderer() |
1542 { | 1542 { |
1543 ASSERT(document().inStyleRecalc()); | 1543 ASSERT(document().inStyleRecalc()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 | 1642 |
1643 RefPtr<LayoutStyle> oldStyle = layoutStyle(); | 1643 RefPtr<LayoutStyle> oldStyle = layoutStyle(); |
1644 RefPtr<LayoutStyle> newStyle = styleForRenderer(); | 1644 RefPtr<LayoutStyle> newStyle = styleForRenderer(); |
1645 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g
et(), newStyle.get()); | 1645 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g
et(), newStyle.get()); |
1646 | 1646 |
1647 ASSERT(newStyle); | 1647 ASSERT(newStyle); |
1648 | 1648 |
1649 if (localChange == Reattach) { | 1649 if (localChange == Reattach) { |
1650 AttachContext reattachContext; | 1650 AttachContext reattachContext; |
1651 reattachContext.resolvedStyle = newStyle.get(); | 1651 reattachContext.resolvedStyle = newStyle.get(); |
1652 bool rendererWillChange = needsAttach() || renderer(); | 1652 bool rendererWillChange = needsAttach() || layoutObject(); |
1653 reattach(reattachContext); | 1653 reattach(reattachContext); |
1654 if (rendererWillChange || renderer()) | 1654 if (rendererWillChange || layoutObject()) |
1655 return Reattach; | 1655 return Reattach; |
1656 return ReattachNoLayoutObject; | 1656 return ReattachNoLayoutObject; |
1657 } | 1657 } |
1658 | 1658 |
1659 ASSERT(oldStyle); | 1659 ASSERT(oldStyle); |
1660 | 1660 |
1661 if (localChange != NoChange) | 1661 if (localChange != NoChange) |
1662 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1662 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
1663 | 1663 |
1664 if (LayoutObject* renderer = this->renderer()) { | 1664 if (LayoutObject* renderer = this->layoutObject()) { |
1665 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(),
newStyle.get()) || svgFilterNeedsLayerUpdate()) { | 1665 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(),
newStyle.get()) || svgFilterNeedsLayerUpdate()) { |
1666 renderer->setStyle(newStyle.get()); | 1666 renderer->setStyle(newStyle.get()); |
1667 } else { | 1667 } else { |
1668 // Although no change occurred, we use the new style so that the cou
sin style sharing code won't get | 1668 // Although no change occurred, we use the new style so that the cou
sin style sharing code won't get |
1669 // fooled into believing this style is the same. | 1669 // fooled into believing this style is the same. |
1670 // FIXME: We may be able to remove this hack, see discussion in | 1670 // FIXME: We may be able to remove this hack, see discussion in |
1671 // https://codereview.chromium.org/30453002/ | 1671 // https://codereview.chromium.org/30453002/ |
1672 renderer->setStyleInternal(newStyle.get()); | 1672 renderer->setStyleInternal(newStyle.get()); |
1673 } | 1673 } |
1674 } | 1674 } |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2176 // When focusing an editable element in an iframe, don't reset the selec
tion if it already contains a selection. | 2176 // When focusing an editable element in an iframe, don't reset the selec
tion if it already contains a selection. |
2177 if (this == frame->selection().rootEditableElement()) | 2177 if (this == frame->selection().rootEditableElement()) |
2178 return; | 2178 return; |
2179 | 2179 |
2180 // FIXME: We should restore the previous selection if there is one. | 2180 // FIXME: We should restore the previous selection if there is one. |
2181 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore
Node(this), DOWNSTREAM); | 2181 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore
Node(this), DOWNSTREAM); |
2182 // Passing DoNotSetFocus as this function is called after FocusControlle
r::setFocusedElement() | 2182 // Passing DoNotSetFocus as this function is called after FocusControlle
r::setFocusedElement() |
2183 // and we don't want to change the focus to a new Element. | 2183 // and we don't want to change the focus to a new Element. |
2184 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi
ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); | 2184 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi
ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); |
2185 frame->selection().revealSelection(); | 2185 frame->selection().revealSelection(); |
2186 } else if (renderer() && !renderer()->isLayoutPart()) | 2186 } else if (layoutObject() && !layoutObject()->isLayoutPart()) { |
2187 renderer()->scrollRectToVisible(boundingBox()); | 2187 layoutObject()->scrollRectToVisible(boundingBox()); |
| 2188 } |
2188 } | 2189 } |
2189 | 2190 |
2190 void Element::blur() | 2191 void Element::blur() |
2191 { | 2192 { |
2192 cancelFocusAppearanceUpdate(); | 2193 cancelFocusAppearanceUpdate(); |
2193 if (treeScope().adjustedFocusedElement() == this) { | 2194 if (treeScope().adjustedFocusedElement() == this) { |
2194 Document& doc = document(); | 2195 Document& doc = document(); |
2195 if (doc.page()) | 2196 if (doc.page()) |
2196 doc.page()->focusController().setFocusedElement(0, doc.frame()); | 2197 doc.page()->focusController().setFocusedElement(0, doc.frame()); |
2197 else | 2198 else |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2405 if (!fragment) | 2406 if (!fragment) |
2406 return; | 2407 return; |
2407 insertAdjacent(where, fragment.get(), exceptionState); | 2408 insertAdjacent(where, fragment.get(), exceptionState); |
2408 } | 2409 } |
2409 | 2410 |
2410 String Element::innerText() | 2411 String Element::innerText() |
2411 { | 2412 { |
2412 // We need to update layout, since plainText uses line boxes in the render t
ree. | 2413 // We need to update layout, since plainText uses line boxes in the render t
ree. |
2413 document().updateLayoutIgnorePendingStylesheets(); | 2414 document().updateLayoutIgnorePendingStylesheets(); |
2414 | 2415 |
2415 if (!renderer()) | 2416 if (!layoutObject()) |
2416 return textContent(true); | 2417 return textContent(true); |
2417 | 2418 |
2418 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); | 2419 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); |
2419 } | 2420 } |
2420 | 2421 |
2421 String Element::outerText() | 2422 String Element::outerText() |
2422 { | 2423 { |
2423 // Getting outerText is the same as getting innerText, only | 2424 // Getting outerText is the same as getting innerText, only |
2424 // setting is different. You would think this should get the plain | 2425 // setting is different. You would think this should get the plain |
2425 // text for the outer range, but this is wrong, <br> for instance | 2426 // text for the outer range, but this is wrong, <br> for instance |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 ASSERT(!needsStyleRecalc()); | 2601 ASSERT(!needsStyleRecalc()); |
2601 PseudoElement* element = pseudoElement(pseudoId); | 2602 PseudoElement* element = pseudoElement(pseudoId); |
2602 | 2603 |
2603 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS
tyle(change))) { | 2604 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS
tyle(change))) { |
2604 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) | 2605 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) |
2605 return; | 2606 return; |
2606 | 2607 |
2607 // Need to clear the cached style if the PseudoElement wants a recalc so
it | 2608 // Need to clear the cached style if the PseudoElement wants a recalc so
it |
2608 // computes a new style. | 2609 // computes a new style. |
2609 if (element->needsStyleRecalc()) | 2610 if (element->needsStyleRecalc()) |
2610 renderer()->style()->removeCachedPseudoStyle(pseudoId); | 2611 layoutObject()->style()->removeCachedPseudoStyle(pseudoId); |
2611 | 2612 |
2612 // PseudoElement styles hang off their parent element's style so if we n
eeded | 2613 // PseudoElement styles hang off their parent element's style so if we n
eeded |
2613 // a style recalc we should Force one on the pseudo. | 2614 // a style recalc we should Force one on the pseudo. |
2614 // FIXME: We should figure out the right text sibling to pass. | 2615 // FIXME: We should figure out the right text sibling to pass. |
2615 element->recalcStyle(change == UpdatePseudoElements ? Force : change); | 2616 element->recalcStyle(change == UpdatePseudoElements ? Force : change); |
2616 | 2617 |
2617 // Wait until our parent is not displayed or pseudoElementRendererIsNeed
ed | 2618 // Wait until our parent is not displayed or pseudoElementRendererIsNeed
ed |
2618 // is false, otherwise we could continuously create and destroy PseudoEl
ements | 2619 // is false, otherwise we could continuously create and destroy PseudoEl
ements |
2619 // when LayoutObject::isChildAllowed on our parent returns false for the | 2620 // when LayoutObject::isChildAllowed on our parent returns false for the |
2620 // PseudoElement's renderer for each style recalc. | 2621 // PseudoElement's renderer for each style recalc. |
2621 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP
seudoStyle(pseudoId))) | 2622 if (!layoutObject() || !pseudoElementRendererIsNeeded(layoutObject()->ge
tCachedPseudoStyle(pseudoId))) |
2622 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2623 elementRareData()->setPseudoElement(pseudoId, nullptr); |
2623 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem
ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) { | 2624 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem
ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) { |
2624 // This can happen if we change to a float, for example. We need to clea
nup the | 2625 // This can happen if we change to a float, for example. We need to clea
nup the |
2625 // first-letter pseudoElement and then fix the text of the original rema
ining | 2626 // first-letter pseudoElement and then fix the text of the original rema
ining |
2626 // text renderer. | 2627 // text renderer. |
2627 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm
l | 2628 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm
l |
2628 elementRareData()->setPseudoElement(pseudoId, nullptr); | 2629 elementRareData()->setPseudoElement(pseudoId, nullptr); |
2629 } else if (change >= UpdatePseudoElements) { | 2630 } else if (change >= UpdatePseudoElements) { |
2630 createPseudoElementIfNeeded(pseudoId); | 2631 createPseudoElementIfNeeded(pseudoId); |
2631 } | 2632 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2672 } | 2673 } |
2673 | 2674 |
2674 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const | 2675 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const |
2675 { | 2676 { |
2676 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr; | 2677 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr; |
2677 } | 2678 } |
2678 | 2679 |
2679 LayoutObject* Element::pseudoElementRenderer(PseudoId pseudoId) const | 2680 LayoutObject* Element::pseudoElementRenderer(PseudoId pseudoId) const |
2680 { | 2681 { |
2681 if (PseudoElement* element = pseudoElement(pseudoId)) | 2682 if (PseudoElement* element = pseudoElement(pseudoId)) |
2682 return element->renderer(); | 2683 return element->layoutObject(); |
2683 return nullptr; | 2684 return nullptr; |
2684 } | 2685 } |
2685 | 2686 |
2686 bool Element::matches(const String& selectors, ExceptionState& exceptionState) | 2687 bool Element::matches(const String& selectors, ExceptionState& exceptionState) |
2687 { | 2688 { |
2688 SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicStr
ing(selectors), document(), exceptionState); | 2689 SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicStr
ing(selectors), document(), exceptionState); |
2689 if (!selectorQuery) | 2690 if (!selectorQuery) |
2690 return false; | 2691 return false; |
2691 return selectorQuery->matches(*this); | 2692 return selectorQuery->matches(*this); |
2692 } | 2693 } |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3371 { | 3372 { |
3372 #if ENABLE(OILPAN) | 3373 #if ENABLE(OILPAN) |
3373 if (hasRareData()) | 3374 if (hasRareData()) |
3374 visitor->trace(elementRareData()); | 3375 visitor->trace(elementRareData()); |
3375 visitor->trace(m_elementData); | 3376 visitor->trace(m_elementData); |
3376 #endif | 3377 #endif |
3377 ContainerNode::trace(visitor); | 3378 ContainerNode::trace(visitor); |
3378 } | 3379 } |
3379 | 3380 |
3380 } // namespace blink | 3381 } // namespace blink |
OLD | NEW |