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

Side by Side Diff: Source/core/dom/Document.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 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // The origin of the Document is the origin it was assigned when its bro wsing context was created. 309 // The origin of the Document is the origin it was assigned when its bro wsing context was created.
310 // 310 //
311 // Note: We generalize this to all "blank" URLs and invalid URLs because we 311 // Note: We generalize this to all "blank" URLs and invalid URLs because we
312 // treat all of these URLs as about:blank. 312 // treat all of these URLs as about:blank.
313 // 313 //
314 return url.isEmpty() || url.protocolIsAbout(); 314 return url.isEmpty() || url.protocolIsAbout();
315 } 315 }
316 316
317 static Widget* widgetForElement(const Element& focusedElement) 317 static Widget* widgetForElement(const Element& focusedElement)
318 { 318 {
319 LayoutObject* renderer = focusedElement.renderer(); 319 LayoutObject* renderer = focusedElement.layoutObject();
320 if (!renderer || !renderer->isLayoutPart()) 320 if (!renderer || !renderer->isLayoutPart())
321 return 0; 321 return 0;
322 return toLayoutPart(renderer)->widget(); 322 return toLayoutPart(renderer)->widget();
323 } 323 }
324 324
325 static bool acceptsEditingFocus(const Element& element) 325 static bool acceptsEditingFocus(const Element& element)
326 { 326 {
327 ASSERT(element.hasEditableStyle()); 327 ASSERT(element.hasEditableStyle());
328 328
329 return element.document().frame() && element.rootEditableElement(); 329 return element.document().frame() && element.rootEditableElement();
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 if (!layoutView()) 1251 if (!layoutView())
1252 return Vector<Element*>(); 1252 return Vector<Element*>();
1253 return TreeScope::elementsFromPoint(x, y); 1253 return TreeScope::elementsFromPoint(x, y);
1254 } 1254 }
1255 1255
1256 PassRefPtrWillBeRawPtr<Range> Document::caretRangeFromPoint(int x, int y) 1256 PassRefPtrWillBeRawPtr<Range> Document::caretRangeFromPoint(int x, int y)
1257 { 1257 {
1258 if (!layoutView()) 1258 if (!layoutView())
1259 return nullptr; 1259 return nullptr;
1260 HitTestResult result = hitTestInDocument(this, x, y); 1260 HitTestResult result = hitTestInDocument(this, x, y);
1261 LayoutObject* renderer = result.renderer(); 1261 LayoutObject* renderer = result.layoutObject();
1262 if (!renderer) 1262 if (!renderer)
1263 return nullptr; 1263 return nullptr;
1264 1264
1265 Node* node = renderer->node(); 1265 Node* node = renderer->node();
1266 Node* shadowAncestorNode = ancestorInThisScope(node); 1266 Node* shadowAncestorNode = ancestorInThisScope(node);
1267 if (shadowAncestorNode != node) { 1267 if (shadowAncestorNode != node) {
1268 unsigned offset = shadowAncestorNode->nodeIndex(); 1268 unsigned offset = shadowAncestorNode->nodeIndex();
1269 ContainerNode* container = shadowAncestorNode->parentNode(); 1269 ContainerNode* container = shadowAncestorNode->parentNode();
1270 return Range::create(*this, container, offset, container, offset); 1270 return Range::create(*this, container, offset, container, offset);
1271 } 1271 }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin. 1748 // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
1749 1749
1750 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits()) 1750 if (m_elemSheet && m_elemSheet->contents()->usesRemUnits())
1751 m_styleEngine->setUsesRemUnit(true); 1751 m_styleEngine->setUsesRemUnit(true);
1752 1752
1753 updateStyle(change); 1753 updateStyle(change);
1754 1754
1755 // As a result of the style recalculation, the currently hovered element mig ht have been 1755 // As a result of the style recalculation, the currently hovered element mig ht have been
1756 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event 1756 // detached (for example, by setting display:none in the :hover style), sche dule another mouseMove event
1757 // to check if any other elements ended up under the mouse pointer due to re -layout. 1757 // to check if any other elements ended up under the mouse pointer due to re -layout.
1758 if (hoverNode() && !hoverNode()->renderer() && frame()) 1758 if (hoverNode() && !hoverNode()->layoutObject() && frame())
1759 frame()->eventHandler().dispatchFakeMouseMoveEventSoon(); 1759 frame()->eventHandler().dispatchFakeMouseMoveEventSoon();
1760 1760
1761 if (m_focusedElement && !m_focusedElement->isFocusable()) 1761 if (m_focusedElement && !m_focusedElement->isFocusable())
1762 clearFocusedElementSoon(); 1762 clearFocusedElementSoon();
1763 1763
1764 ASSERT(!m_timeline->hasOutdatedAnimationPlayer()); 1764 ASSERT(!m_timeline->hasOutdatedAnimationPlayer());
1765 1765
1766 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalculat eStyles", "elementCount", m_styleRecalcElementCounter); 1766 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalculat eStyles", "elementCount", m_styleRecalcElementCounter);
1767 TRACE_EVENT_END1("blink", "Document::updateRenderTree", "elementCount", m_st yleRecalcElementCounter); 1767 TRACE_EVENT_END1("blink", "Document::updateRenderTree", "elementCount", m_st yleRecalcElementCounter);
1768 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter); 1768 InspectorInstrumentation::didRecalculateStyle(cookie, m_styleRecalcElementCo unter);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 1909
1910 if (m_styleEngine->hasPendingSheets()) { 1910 if (m_styleEngine->hasPendingSheets()) {
1911 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once. 1911 // FIXME: We are willing to attempt to suppress painting with outdated s tyle info only once.
1912 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page 1912 // Our assumption is that it would be dangerous to try to stop it a seco nd time, after page
1913 // content has already been loaded and displayed with accurate style inf ormation. (Our 1913 // content has already been loaded and displayed with accurate style inf ormation. (Our
1914 // suppression involves blanking the whole page at the moment. If it wer e more refined, we 1914 // suppression involves blanking the whole page at the moment. If it wer e more refined, we
1915 // might be able to do something better.) It's worth noting though that this entire method 1915 // might be able to do something better.) It's worth noting though that this entire method
1916 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with 1916 // is a hack, since what we really want to do is suspend JS instead of d oing a layout with
1917 // inaccurate information. 1917 // inaccurate information.
1918 HTMLElement* bodyElement = body(); 1918 HTMLElement* bodyElement = body();
1919 if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == N oLayoutWithPendingSheets) { 1919 if (bodyElement && !bodyElement->layoutObject() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
1920 m_pendingSheetLayout = DidLayoutWithPendingSheets; 1920 m_pendingSheetLayout = DidLayoutWithPendingSheets;
1921 styleResolverChanged(); 1921 styleResolverChanged();
1922 } else if (m_hasNodesWithPlaceholderStyle) { 1922 } else if (m_hasNodesWithPlaceholderStyle) {
1923 // If new nodes have been added or style recalc has been done with s tyle sheets still 1923 // If new nodes have been added or style recalc has been done with s tyle sheets still
1924 // pending, some nodes may not have had their real style calculated yet. Normally this 1924 // pending, some nodes may not have had their real style calculated yet. Normally this
1925 // gets cleaned when style sheets arrive but here we need up-to-date style immediately. 1925 // gets cleaned when style sheets arrive but here we need up-to-date style immediately.
1926 updateRenderTree(Force); 1926 updateRenderTree(Force);
1927 } 1927 }
1928 } 1928 }
1929 1929
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 if (frame()->navigationScheduler().locationChangePending() && elapsedTime() < cLayoutScheduleThreshold) { 2505 if (frame()->navigationScheduler().locationChangePending() && elapsedTime() < cLayoutScheduleThreshold) {
2506 // Just bail out. Before or during the onload we were shifted to another page. 2506 // Just bail out. Before or during the onload we were shifted to another page.
2507 // The old i-Bench suite does this. When this happens don't bother paint ing or laying out. 2507 // The old i-Bench suite does this. When this happens don't bother paint ing or laying out.
2508 m_loadEventProgress = LoadEventCompleted; 2508 m_loadEventProgress = LoadEventCompleted;
2509 return; 2509 return;
2510 } 2510 }
2511 2511
2512 // We used to force a synchronous display and flush here. This really isn't 2512 // We used to force a synchronous display and flush here. This really isn't
2513 // necessary and can in fact be actively harmful if pages are loading at a r ate of > 60fps 2513 // necessary and can in fact be actively harmful if pages are loading at a r ate of > 60fps
2514 // (if your platform is syncing flushes and limiting them to 60fps). 2514 // (if your platform is syncing flushes and limiting them to 60fps).
2515 if (!ownerElement() || (ownerElement()->renderer() && !ownerElement()->rende rer()->needsLayout())) { 2515 if (!ownerElement() || (ownerElement()->layoutObject() && !ownerElement()->l ayoutObject()->needsLayout())) {
2516 updateRenderTreeIfNeeded(); 2516 updateRenderTreeIfNeeded();
2517 2517
2518 // Always do a layout after loading if needed. 2518 // Always do a layout after loading if needed.
2519 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView ()->needsLayout())) 2519 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView ()->needsLayout()))
2520 view()->layout(); 2520 view()->layout();
2521 } 2521 }
2522 2522
2523 m_loadEventProgress = LoadEventCompleted; 2523 m_loadEventProgress = LoadEventCompleted;
2524 2524
2525 if (frame() && layoutView() && settings()->accessibilityEnabled()) { 2525 if (frame() && layoutView() && settings()->accessibilityEnabled()) {
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 { 3364 {
3365 ASSERT(node); 3365 ASSERT(node);
3366 if (!m_hoverNode) 3366 if (!m_hoverNode)
3367 return; 3367 return;
3368 3368
3369 m_hoverNode->updateDistribution(); 3369 m_hoverNode->updateDistribution();
3370 if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != NodeRender ingTraversal::parent(*m_hoverNode))) 3370 if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != NodeRender ingTraversal::parent(*m_hoverNode)))
3371 return; 3371 return;
3372 3372
3373 m_hoverNode = NodeRenderingTraversal::parent(*node); 3373 m_hoverNode = NodeRenderingTraversal::parent(*node);
3374 while (m_hoverNode && !m_hoverNode->renderer()) 3374 while (m_hoverNode && !m_hoverNode->layoutObject())
3375 m_hoverNode = NodeRenderingTraversal::parent(*m_hoverNode); 3375 m_hoverNode = NodeRenderingTraversal::parent(*m_hoverNode);
3376 3376
3377 // If the mouse cursor is not visible, do not clear existing 3377 // If the mouse cursor is not visible, do not clear existing
3378 // hover effects on the ancestors of |node| and do not invoke 3378 // hover effects on the ancestors of |node| and do not invoke
3379 // new hover effects on any other element. 3379 // new hover effects on any other element.
3380 if (!page()->isCursorVisible()) 3380 if (!page()->isCursorVisible())
3381 return; 3381 return;
3382 3382
3383 if (frame()) 3383 if (frame())
3384 frame()->eventHandler().scheduleHoverStateUpdate(); 3384 frame()->eventHandler().scheduleHoverStateUpdate();
3385 } 3385 }
3386 3386
3387 void Document::activeChainNodeDetached(Node* node) 3387 void Document::activeChainNodeDetached(Node* node)
3388 { 3388 {
3389 if (!m_activeHoverElement) 3389 if (!m_activeHoverElement)
3390 return; 3390 return;
3391 3391
3392 if (node != m_activeHoverElement) 3392 if (node != m_activeHoverElement)
3393 return; 3393 return;
3394 3394
3395 Node* activeNode = NodeRenderingTraversal::parent(*node); 3395 Node* activeNode = NodeRenderingTraversal::parent(*node);
3396 while (activeNode && activeNode->isElementNode() && !activeNode->renderer()) 3396 while (activeNode && activeNode->isElementNode() && !activeNode->layoutObjec t())
3397 activeNode = NodeRenderingTraversal::parent(*activeNode); 3397 activeNode = NodeRenderingTraversal::parent(*activeNode);
3398 3398
3399 m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement (activeNode) : 0; 3399 m_activeHoverElement = activeNode && activeNode->isElementNode() ? toElement (activeNode) : 0;
3400 } 3400 }
3401 3401
3402 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const 3402 const Vector<AnnotatedRegionValue>& Document::annotatedRegions() const
3403 { 3403 {
3404 return m_annotatedRegions; 3404 return m_annotatedRegions;
3405 } 3405 }
3406 3406
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
5258 // If the mouse is down and if this is a mouse move event, we want to restri ct changes in 5258 // If the mouse is down and if this is a mouse move event, we want to restri ct changes in
5259 // :hover/:active to only apply to elements that are in the :active chain th at we froze 5259 // :hover/:active to only apply to elements that are in the :active chain th at we froze
5260 // at the time the mouse went down. 5260 // at the time the mouse went down.
5261 bool mustBeInActiveChain = request.active() && request.move(); 5261 bool mustBeInActiveChain = request.active() && request.move();
5262 5262
5263 RefPtrWillBeRawPtr<Node> oldHoverNode = hoverNode(); 5263 RefPtrWillBeRawPtr<Node> oldHoverNode = hoverNode();
5264 5264
5265 // Check to see if the hovered node has changed. 5265 // Check to see if the hovered node has changed.
5266 // If it hasn't, we do not need to do anything. 5266 // If it hasn't, we do not need to do anything.
5267 Node* newHoverNode = innerElementInDocument; 5267 Node* newHoverNode = innerElementInDocument;
5268 while (newHoverNode && !newHoverNode->renderer()) 5268 while (newHoverNode && !newHoverNode->layoutObject())
5269 newHoverNode = newHoverNode->parentOrShadowHostNode(); 5269 newHoverNode = newHoverNode->parentOrShadowHostNode();
5270 5270
5271 // Update our current hover node. 5271 // Update our current hover node.
5272 setHoverNode(newHoverNode); 5272 setHoverNode(newHoverNode);
5273 5273
5274 // We have two different objects. Fetch their renderers. 5274 // We have two different objects. Fetch their renderers.
5275 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->renderer() : 0; 5275 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0;
5276 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->renderer() : 0; 5276 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0;
5277 5277
5278 // Locate the common ancestor render object for the two renderers. 5278 // Locate the common ancestor render object for the two renderers.
5279 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj ); 5279 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj );
5280 RefPtrWillBeRawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0); 5280 RefPtrWillBeRawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0);
5281 5281
5282 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToRemoveFromChain; 5282 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToRemoveFromChain;
5283 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToAddToChain; 5283 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToAddToChain;
5284 5284
5285 if (oldHoverObj != newHoverObj) { 5285 if (oldHoverObj != newHoverObj) {
5286 // If the old hovered node is not nil but it's renderer is, it was proba bly detached as part of the :hover style 5286 // If the old hovered node is not nil but it's renderer is, it was proba bly detached as part of the :hover style
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
5733 #ifndef NDEBUG 5733 #ifndef NDEBUG
5734 using namespace blink; 5734 using namespace blink;
5735 void showLiveDocumentInstances() 5735 void showLiveDocumentInstances()
5736 { 5736 {
5737 WeakDocumentSet& set = liveDocumentSet(); 5737 WeakDocumentSet& set = liveDocumentSet();
5738 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5738 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5739 for (Document* document : set) 5739 for (Document* document : set)
5740 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5740 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5741 } 5741 }
5742 #endif 5742 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698