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

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

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase to master Created 5 years, 9 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 | Annotate | Revision Log
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. 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
229 return hasRareData() ? elementRareData()->tabIndex() : 0; 229 return hasRareData() ? elementRareData()->tabIndex() : 0;
230 } 230 }
231 231
232 bool Element::rendererIsFocusable() const 232 bool Element::rendererIsFocusable() 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
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
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())
Julien - ping for review 2015/03/05 16:19:15 Ditto.
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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 863
864 IntRect Element::boundsInViewportSpace() 864 IntRect Element::boundsInViewportSpace()
865 { 865 {
866 document().updateLayoutIgnorePendingStylesheets(); 866 document().updateLayoutIgnorePendingStylesheets();
867 867
868 FrameView* view = document().view(); 868 FrameView* view = document().view();
869 if (!view) 869 if (!view)
870 return IntRect(); 870 return IntRect();
871 871
872 Vector<FloatQuad> quads; 872 Vector<FloatQuad> quads;
873 if (isSVGElement() && renderer()) { 873 if (isSVGElement() && layoutObject()) {
874 // Get the bounding rectangle from the SVG model. 874 // Get the bounding rectangle from the SVG model.
875 SVGElement* svgElement = toSVGElement(this); 875 SVGElement* svgElement = toSVGElement(this);
876 FloatRect localRect; 876 FloatRect localRect;
877 if (svgElement->getBoundingBox(localRect)) 877 if (svgElement->getBoundingBox(localRect))
878 quads.append(renderer()->localToAbsoluteQuad(localRect)); 878 quads.append(layoutObject()->localToAbsoluteQuad(localRect));
879 } else { 879 } else {
880 // Get the bounding rectangle from the box model. 880 // Get the bounding rectangle from the box model.
881 if (layoutBoxModelObject()) 881 if (layoutBoxModelObject())
882 layoutBoxModelObject()->absoluteQuads(quads); 882 layoutBoxModelObject()->absoluteQuads(quads);
883 } 883 }
884 884
885 if (quads.isEmpty()) 885 if (quads.isEmpty())
886 return IntRect(); 886 return IntRect();
887 887
888 IntRect result = quads[0].enclosingBoundingBox(); 888 IntRect result = quads[0].enclosingBoundingBox();
889 for (size_t i = 1; i < quads.size(); ++i) 889 for (size_t i = 1; i < quads.size(); ++i)
890 result.unite(quads[i].enclosingBoundingBox()); 890 result.unite(quads[i].enclosingBoundingBox());
891 891
892 result = view->contentsToWindow(result); 892 result = view->contentsToWindow(result);
893 893
894 // FIXME: Cleanup pinch viewport coordinate translations. crbug.com/371902. 894 // FIXME: Cleanup pinch viewport coordinate translations. crbug.com/371902.
895 PinchViewport& pinchViewport = document().page()->frameHost().pinchViewport( ); 895 PinchViewport& pinchViewport = document().page()->frameHost().pinchViewport( );
896 result = enclosingIntRect(pinchViewport.mainViewToViewportCSSPixels(result)) ; 896 result = enclosingIntRect(pinchViewport.mainViewToViewportCSSPixels(result)) ;
897 897
898 return result; 898 return result;
899 } 899 }
900 900
901 PassRefPtrWillBeRawPtr<ClientRectList> Element::getClientRects() 901 PassRefPtrWillBeRawPtr<ClientRectList> Element::getClientRects()
902 { 902 {
903 document().updateLayoutIgnorePendingStylesheets(); 903 document().updateLayoutIgnorePendingStylesheets();
904 904
905 LayoutObject* elementRenderer = renderer(); 905 LayoutObject* elementRenderer = layoutObject();
906 if (!elementRenderer || (!elementRenderer->isBoxModelObject() && !elementRen derer->isBR())) 906 if (!elementRenderer || (!elementRenderer->isBoxModelObject() && !elementRen derer->isBR()))
907 return ClientRectList::create(); 907 return ClientRectList::create();
908 908
909 // FIXME: Handle SVG elements. 909 // FIXME: Handle SVG elements.
910 // FIXME: Handle table/inline-table with a caption. 910 // FIXME: Handle table/inline-table with a caption.
911 911
912 Vector<FloatQuad> quads; 912 Vector<FloatQuad> quads;
913 elementRenderer->absoluteQuads(quads); 913 elementRenderer->absoluteQuads(quads);
914 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementRenderer) ; 914 document().adjustFloatQuadsForScrollAndAbsoluteZoom(quads, *elementRenderer) ;
915 return ClientRectList::create(quads); 915 return ClientRectList::create(quads);
916 } 916 }
917 917
918 PassRefPtrWillBeRawPtr<ClientRect> Element::getBoundingClientRect() 918 PassRefPtrWillBeRawPtr<ClientRect> Element::getBoundingClientRect()
919 { 919 {
920 document().updateLayoutIgnorePendingStylesheets(); 920 document().updateLayoutIgnorePendingStylesheets();
921 921
922 Vector<FloatQuad> quads; 922 Vector<FloatQuad> quads;
923 LayoutObject* elementRenderer = renderer(); 923 LayoutObject* elementRenderer = layoutObject();
Julien - ping for review 2015/03/05 16:19:15 s/Renderer/LayoutObject/
924 if (elementRenderer) { 924 if (elementRenderer) {
925 if (isSVGElement() && !elementRenderer->isSVGRoot()) { 925 if (isSVGElement() && !elementRenderer->isSVGRoot()) {
926 // Get the bounding rectangle from the SVG model. 926 // Get the bounding rectangle from the SVG model.
927 SVGElement* svgElement = toSVGElement(this); 927 SVGElement* svgElement = toSVGElement(this);
928 FloatRect localRect; 928 FloatRect localRect;
929 if (svgElement->getBoundingBox(localRect)) 929 if (svgElement->getBoundingBox(localRect))
930 quads.append(elementRenderer->localToAbsoluteQuad(localRect)); 930 quads.append(elementRenderer->localToAbsoluteQuad(localRect));
931 } else if (elementRenderer->isBoxModelObject() || elementRenderer->isBR( )) { 931 } else if (elementRenderer->isBoxModelObject() || elementRenderer->isBR( )) {
932 elementRenderer->absoluteQuads(quads); 932 elementRenderer->absoluteQuads(quads);
933 } 933 }
934 } 934 }
935 935
936 if (quads.isEmpty()) 936 if (quads.isEmpty())
937 return ClientRect::create(); 937 return ClientRect::create();
938 938
939 FloatRect result = quads[0].boundingBox(); 939 FloatRect result = quads[0].boundingBox();
940 for (size_t i = 1; i < quads.size(); ++i) 940 for (size_t i = 1; i < quads.size(); ++i)
941 result.unite(quads[i].boundingBox()); 941 result.unite(quads[i].boundingBox());
942 942
943 ASSERT(elementRenderer); 943 ASSERT(elementRenderer);
944 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementRenderer) ; 944 document().adjustFloatRectForScrollAndAbsoluteZoom(result, *elementRenderer) ;
945 return ClientRect::create(result); 945 return ClientRect::create(result);
946 } 946 }
947 947
948 IntRect Element::screenRect() const 948 IntRect Element::screenRect() const
949 { 949 {
950 if (!renderer()) 950 if (!layoutObject())
951 return IntRect(); 951 return IntRect();
952 // FIXME: this should probably respect transforms 952 // FIXME: this should probably respect transforms
953 return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRe ctIgnoringTransforms()); 953 return document().view()->contentsToScreen(layoutObject()->absoluteBoundingB oxRectIgnoringTransforms());
954 } 954 }
955 955
956 const AtomicString& Element::computedRole() 956 const AtomicString& Element::computedRole()
957 { 957 {
958 document().updateLayoutIgnorePendingStylesheets(); 958 document().updateLayoutIgnorePendingStylesheets();
959 ScopedAXObjectCache cache(document()); 959 ScopedAXObjectCache cache(document());
960 return cache->computedRoleForNode(this); 960 return cache->computedRoleForNode(this);
961 } 961 }
962 962
963 String Element::computedName() 963 String Element::computedName()
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 ContainerNode::attach(context); 1440 ContainerNode::attach(context);
1441 1441
1442 createPseudoElementIfNeeded(AFTER); 1442 createPseudoElementIfNeeded(AFTER);
1443 createPseudoElementIfNeeded(BACKDROP); 1443 createPseudoElementIfNeeded(BACKDROP);
1444 1444
1445 // We create the first-letter element after the :before, :after and 1445 // We create the first-letter element after the :before, :after and
1446 // children are attached because the first letter text could come 1446 // children are attached because the first letter text could come
1447 // from any of them. 1447 // from any of them.
1448 createPseudoElementIfNeeded(FIRST_LETTER); 1448 createPseudoElementIfNeeded(FIRST_LETTER);
1449 1449
1450 if (hasRareData() && !renderer()) { 1450 if (hasRareData() && !layoutObject()) {
1451 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) { 1451 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) {
1452 elementAnimations->cssAnimations().cancel(); 1452 elementAnimations->cssAnimations().cancel();
1453 elementAnimations->setAnimationStyleChange(false); 1453 elementAnimations->setAnimationStyleChange(false);
1454 } 1454 }
1455 } 1455 }
1456 } 1456 }
1457 1457
1458 void Element::detach(const AttachContext& context) 1458 void Element::detach(const AttachContext& context)
1459 { 1459 {
1460 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1460 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
(...skipping 29 matching lines...) Expand all
1490 ContainerNode::detach(context); 1490 ContainerNode::detach(context);
1491 1491
1492 ASSERT(needsAttach()); 1492 ASSERT(needsAttach());
1493 if (svgFilterNeedsLayerUpdate()) 1493 if (svgFilterNeedsLayerUpdate())
1494 document().unscheduleSVGFilterLayerUpdateHack(*this); 1494 document().unscheduleSVGFilterLayerUpdateHack(*this);
1495 } 1495 }
1496 1496
1497 bool Element::pseudoStyleCacheIsInvalid(const LayoutStyle* currentStyle, LayoutS tyle* newStyle) 1497 bool Element::pseudoStyleCacheIsInvalid(const LayoutStyle* currentStyle, LayoutS tyle* newStyle)
1498 { 1498 {
1499 ASSERT(currentStyle == layoutStyle()); 1499 ASSERT(currentStyle == layoutStyle());
1500 ASSERT(renderer()); 1500 ASSERT(layoutObject());
1501 1501
1502 if (!currentStyle) 1502 if (!currentStyle)
1503 return false; 1503 return false;
1504 1504
1505 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles( ); 1505 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles( );
1506 if (!pseudoStyleCache) 1506 if (!pseudoStyleCache)
1507 return false; 1507 return false;
1508 1508
1509 size_t cacheSize = pseudoStyleCache->size(); 1509 size_t cacheSize = pseudoStyleCache->size();
1510 for (size_t i = 0; i < cacheSize; ++i) { 1510 for (size_t i = 0; i < cacheSize; ++i) {
1511 RefPtr<LayoutStyle> newPseudoStyle; 1511 RefPtr<LayoutStyle> newPseudoStyle;
1512 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType(); 1512 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType();
1513 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) 1513 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED)
1514 newPseudoStyle = renderer()->uncachedFirstLineStyle(newStyle); 1514 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle);
1515 else 1515 else
1516 newPseudoStyle = renderer()->getUncachedPseudoStyle(PseudoStyleReque st(pseudoId), newStyle, newStyle); 1516 newPseudoStyle = layoutObject()->getUncachedPseudoStyle(PseudoStyleR equest(pseudoId), newStyle, newStyle);
1517 if (!newPseudoStyle) 1517 if (!newPseudoStyle)
1518 return true; 1518 return true;
1519 if (*newPseudoStyle != *pseudoStyleCache->at(i)) { 1519 if (*newPseudoStyle != *pseudoStyleCache->at(i)) {
1520 if (pseudoId < FIRST_INTERNAL_PSEUDOID) 1520 if (pseudoId < FIRST_INTERNAL_PSEUDOID)
1521 newStyle->setHasPseudoStyle(pseudoId); 1521 newStyle->setHasPseudoStyle(pseudoId);
1522 newStyle->addCachedPseudoStyle(newPseudoStyle); 1522 newStyle->addCachedPseudoStyle(newPseudoStyle);
1523 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) { 1523 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) {
1524 // FIXME: We should do an actual diff to determine whether a rep aint vs. layout 1524 // FIXME: We should do an actual diff to determine whether a rep aint vs. layout
1525 // is needed, but for now just assume a layout will be required. The diff code 1525 // is needed, but for now just assume a layout will be required. The diff code
1526 // in LayoutObject::setStyle would need to be factored out so th at it could be reused. 1526 // in LayoutObject::setStyle would need to be factored out so th at it could be reused.
1527 renderer()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalid ation(); 1527 layoutObject()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInv alidation();
1528 } 1528 }
1529 return true; 1529 return true;
1530 } 1530 }
1531 } 1531 }
1532 return false; 1532 return false;
1533 } 1533 }
1534 1534
1535 PassRefPtr<LayoutStyle> Element::styleForRenderer() 1535 PassRefPtr<LayoutStyle> Element::styleForRenderer()
1536 { 1536 {
1537 ASSERT(document().inStyleRecalc()); 1537 ASSERT(document().inStyleRecalc());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 1636
1637 RefPtr<LayoutStyle> oldStyle = layoutStyle(); 1637 RefPtr<LayoutStyle> oldStyle = layoutStyle();
1638 RefPtr<LayoutStyle> newStyle = styleForRenderer(); 1638 RefPtr<LayoutStyle> newStyle = styleForRenderer();
1639 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g et(), newStyle.get()); 1639 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g et(), newStyle.get());
1640 1640
1641 ASSERT(newStyle); 1641 ASSERT(newStyle);
1642 1642
1643 if (localChange == Reattach) { 1643 if (localChange == Reattach) {
1644 AttachContext reattachContext; 1644 AttachContext reattachContext;
1645 reattachContext.resolvedStyle = newStyle.get(); 1645 reattachContext.resolvedStyle = newStyle.get();
1646 bool rendererWillChange = needsAttach() || renderer(); 1646 bool rendererWillChange = needsAttach() || layoutObject();
1647 reattach(reattachContext); 1647 reattach(reattachContext);
1648 if (rendererWillChange || renderer()) 1648 if (rendererWillChange || layoutObject())
1649 return Reattach; 1649 return Reattach;
1650 return ReattachNoRenderer; 1650 return ReattachNoRenderer;
1651 } 1651 }
1652 1652
1653 ASSERT(oldStyle); 1653 ASSERT(oldStyle);
1654 1654
1655 if (localChange != NoChange) 1655 if (localChange != NoChange)
1656 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1656 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1657 1657
1658 if (LayoutObject* renderer = this->renderer()) { 1658 if (LayoutObject* renderer = this->layoutObject()) {
Julien - ping for review 2015/03/05 16:19:15 s/renderer/layoutObject/
1659 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) { 1659 if (localChange != NoChange || pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || svgFilterNeedsLayerUpdate()) {
1660 renderer->setStyle(newStyle.get()); 1660 renderer->setStyle(newStyle.get());
1661 } else { 1661 } else {
1662 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get 1662 // Although no change occurred, we use the new style so that the cou sin style sharing code won't get
1663 // fooled into believing this style is the same. 1663 // fooled into believing this style is the same.
1664 // FIXME: We may be able to remove this hack, see discussion in 1664 // FIXME: We may be able to remove this hack, see discussion in
1665 // https://codereview.chromium.org/30453002/ 1665 // https://codereview.chromium.org/30453002/
1666 renderer->setStyleInternal(newStyle.get()); 1666 renderer->setStyleInternal(newStyle.get());
1667 } 1667 }
1668 } 1668 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection. 2170 // When focusing an editable element in an iframe, don't reset the selec tion if it already contains a selection.
2171 if (this == frame->selection().rootEditableElement()) 2171 if (this == frame->selection().rootEditableElement())
2172 return; 2172 return;
2173 2173
2174 // FIXME: We should restore the previous selection if there is one. 2174 // FIXME: We should restore the previous selection if there is one.
2175 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore Node(this), DOWNSTREAM); 2175 VisibleSelection newSelection = VisibleSelection(firstPositionInOrBefore Node(this), DOWNSTREAM);
2176 // Passing DoNotSetFocus as this function is called after FocusControlle r::setFocusedElement() 2176 // Passing DoNotSetFocus as this function is called after FocusControlle r::setFocusedElement()
2177 // and we don't want to change the focus to a new Element. 2177 // and we don't want to change the focus to a new Element.
2178 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus); 2178 frame->selection().setSelection(newSelection, FrameSelection::CloseTypi ng | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus);
2179 frame->selection().revealSelection(); 2179 frame->selection().revealSelection();
2180 } else if (renderer() && !renderer()->isLayoutPart()) 2180 } else if (layoutObject() && !layoutObject()->isLayoutPart()) {
2181 renderer()->scrollRectToVisible(boundingBox()); 2181 layoutObject()->scrollRectToVisible(boundingBox());
2182 }
2182 } 2183 }
2183 2184
2184 void Element::blur() 2185 void Element::blur()
2185 { 2186 {
2186 cancelFocusAppearanceUpdate(); 2187 cancelFocusAppearanceUpdate();
2187 if (treeScope().adjustedFocusedElement() == this) { 2188 if (treeScope().adjustedFocusedElement() == this) {
2188 Document& doc = document(); 2189 Document& doc = document();
2189 if (doc.page()) 2190 if (doc.page())
2190 doc.page()->focusController().setFocusedElement(0, doc.frame()); 2191 doc.page()->focusController().setFocusedElement(0, doc.frame());
2191 else 2192 else
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 if (!fragment) 2400 if (!fragment)
2400 return; 2401 return;
2401 insertAdjacent(where, fragment.get(), exceptionState); 2402 insertAdjacent(where, fragment.get(), exceptionState);
2402 } 2403 }
2403 2404
2404 String Element::innerText() 2405 String Element::innerText()
2405 { 2406 {
2406 // We need to update layout, since plainText uses line boxes in the render t ree. 2407 // We need to update layout, since plainText uses line boxes in the render t ree.
2407 document().updateLayoutIgnorePendingStylesheets(); 2408 document().updateLayoutIgnorePendingStylesheets();
2408 2409
2409 if (!renderer()) 2410 if (!layoutObject())
2410 return textContent(true); 2411 return textContent(true);
2411 2412
2412 return plainText(rangeOfContents(const_cast<Element*>(this)).get()); 2413 return plainText(rangeOfContents(const_cast<Element*>(this)).get());
2413 } 2414 }
2414 2415
2415 String Element::outerText() 2416 String Element::outerText()
2416 { 2417 {
2417 // Getting outerText is the same as getting innerText, only 2418 // Getting outerText is the same as getting innerText, only
2418 // setting is different. You would think this should get the plain 2419 // setting is different. You would think this should get the plain
2419 // text for the outer range, but this is wrong, <br> for instance 2420 // text for the outer range, but this is wrong, <br> for instance
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 ASSERT(!needsStyleRecalc()); 2595 ASSERT(!needsStyleRecalc());
2595 PseudoElement* element = pseudoElement(pseudoId); 2596 PseudoElement* element = pseudoElement(pseudoId);
2596 2597
2597 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { 2598 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) {
2598 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) 2599 if (pseudoId == FIRST_LETTER && updateFirstLetter(element))
2599 return; 2600 return;
2600 2601
2601 // Need to clear the cached style if the PseudoElement wants a recalc so it 2602 // Need to clear the cached style if the PseudoElement wants a recalc so it
2602 // computes a new style. 2603 // computes a new style.
2603 if (element->needsStyleRecalc()) 2604 if (element->needsStyleRecalc())
2604 renderer()->style()->removeCachedPseudoStyle(pseudoId); 2605 layoutObject()->style()->removeCachedPseudoStyle(pseudoId);
2605 2606
2606 // PseudoElement styles hang off their parent element's style so if we n eeded 2607 // PseudoElement styles hang off their parent element's style so if we n eeded
2607 // a style recalc we should Force one on the pseudo. 2608 // a style recalc we should Force one on the pseudo.
2608 // FIXME: We should figure out the right text sibling to pass. 2609 // FIXME: We should figure out the right text sibling to pass.
2609 element->recalcStyle(change == UpdatePseudoElements ? Force : change); 2610 element->recalcStyle(change == UpdatePseudoElements ? Force : change);
2610 2611
2611 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed 2612 // Wait until our parent is not displayed or pseudoElementRendererIsNeed ed
2612 // is false, otherwise we could continuously create and destroy PseudoEl ements 2613 // is false, otherwise we could continuously create and destroy PseudoEl ements
2613 // when LayoutObject::isChildAllowed on our parent returns false for the 2614 // when LayoutObject::isChildAllowed on our parent returns false for the
2614 // PseudoElement's renderer for each style recalc. 2615 // PseudoElement's renderer for each style recalc.
2615 if (!renderer() || !pseudoElementRendererIsNeeded(renderer()->getCachedP seudoStyle(pseudoId))) 2616 if (!layoutObject() || !pseudoElementRendererIsNeeded(layoutObject()->ge tCachedPseudoStyle(pseudoId)))
2616 elementRareData()->setPseudoElement(pseudoId, nullptr); 2617 elementRareData()->setPseudoElement(pseudoId, nullptr);
2617 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) { 2618 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem ents && !FirstLetterPseudoElement::firstLetterTextRenderer(*element)) {
2618 // This can happen if we change to a float, for example. We need to clea nup the 2619 // This can happen if we change to a float, for example. We need to clea nup the
2619 // first-letter pseudoElement and then fix the text of the original rema ining 2620 // first-letter pseudoElement and then fix the text of the original rema ining
2620 // text renderer. 2621 // text renderer.
2621 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l 2622 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l
2622 elementRareData()->setPseudoElement(pseudoId, nullptr); 2623 elementRareData()->setPseudoElement(pseudoId, nullptr);
2623 } else if (change >= UpdatePseudoElements) { 2624 } else if (change >= UpdatePseudoElements) {
2624 createPseudoElementIfNeeded(pseudoId); 2625 createPseudoElementIfNeeded(pseudoId);
2625 } 2626 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 } 2668 }
2668 2669
2669 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const 2670 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const
2670 { 2671 {
2671 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr; 2672 return hasRareData() ? elementRareData()->pseudoElement(pseudoId) : nullptr;
2672 } 2673 }
2673 2674
2674 LayoutObject* Element::pseudoElementRenderer(PseudoId pseudoId) const 2675 LayoutObject* Element::pseudoElementRenderer(PseudoId pseudoId) const
2675 { 2676 {
2676 if (PseudoElement* element = pseudoElement(pseudoId)) 2677 if (PseudoElement* element = pseudoElement(pseudoId))
2677 return element->renderer(); 2678 return element->layoutObject();
2678 return nullptr; 2679 return nullptr;
2679 } 2680 }
2680 2681
2681 bool Element::matches(const String& selectors, ExceptionState& exceptionState) 2682 bool Element::matches(const String& selectors, ExceptionState& exceptionState)
2682 { 2683 {
2683 SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicStr ing(selectors), document(), exceptionState); 2684 SelectorQuery* selectorQuery = document().selectorQueryCache().add(AtomicStr ing(selectors), document(), exceptionState);
2684 if (!selectorQuery) 2685 if (!selectorQuery)
2685 return false; 2686 return false;
2686 return selectorQuery->matches(*this); 2687 return selectorQuery->matches(*this);
2687 } 2688 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 { 3367 {
3367 #if ENABLE(OILPAN) 3368 #if ENABLE(OILPAN)
3368 if (hasRareData()) 3369 if (hasRareData())
3369 visitor->trace(elementRareData()); 3370 visitor->trace(elementRareData());
3370 visitor->trace(m_elementData); 3371 visitor->trace(m_elementData);
3371 #endif 3372 #endif
3372 ContainerNode::trace(visitor); 3373 ContainerNode::trace(visitor);
3373 } 3374 }
3374 3375
3375 } // namespace blink 3376 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698