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

Side by Side Diff: Source/core/rendering/RenderObject.cpp

Issue 197283025: Use new is*Element() helper functions more in rendering code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « Source/core/rendering/RenderMeter.cpp ('k') | Source/core/rendering/RenderProgress.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
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 24 matching lines...) Expand all
35 #include "core/editing/EditingBoundary.h" 35 #include "core/editing/EditingBoundary.h"
36 #include "core/editing/FrameSelection.h" 36 #include "core/editing/FrameSelection.h"
37 #include "core/editing/htmlediting.h" 37 #include "core/editing/htmlediting.h"
38 #include "core/fetch/ResourceLoadPriorityOptimizer.h" 38 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
39 #include "core/fetch/ResourceLoader.h" 39 #include "core/fetch/ResourceLoader.h"
40 #include "core/frame/FrameView.h" 40 #include "core/frame/FrameView.h"
41 #include "core/frame/LocalFrame.h" 41 #include "core/frame/LocalFrame.h"
42 #include "core/html/HTMLAnchorElement.h" 42 #include "core/html/HTMLAnchorElement.h"
43 #include "core/html/HTMLElement.h" 43 #include "core/html/HTMLElement.h"
44 #include "core/html/HTMLHtmlElement.h" 44 #include "core/html/HTMLHtmlElement.h"
45 #include "core/html/HTMLTableCellElement.h"
45 #include "core/html/HTMLTableElement.h" 46 #include "core/html/HTMLTableElement.h"
46 #include "core/page/AutoscrollController.h" 47 #include "core/page/AutoscrollController.h"
47 #include "core/page/EventHandler.h" 48 #include "core/page/EventHandler.h"
48 #include "core/page/Page.h" 49 #include "core/page/Page.h"
49 #include "core/frame/Settings.h" 50 #include "core/frame/Settings.h"
50 #include "core/frame/UseCounter.h" 51 #include "core/frame/UseCounter.h"
51 #include "core/rendering/FlowThreadController.h" 52 #include "core/rendering/FlowThreadController.h"
52 #include "core/rendering/HitTestResult.h" 53 #include "core/rendering/HitTestResult.h"
53 #include "core/rendering/LayoutRectRecorder.h" 54 #include "core/rendering/LayoutRectRecorder.h"
54 #include "core/rendering/RenderCounter.h" 55 #include "core/rendering/RenderCounter.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 { 242 {
242 for (const RenderObject* r = this; r; r = r->m_parent) { 243 for (const RenderObject* r = this; r; r = r->m_parent) {
243 if (r == obj) 244 if (r == obj)
244 return true; 245 return true;
245 } 246 }
246 return false; 247 return false;
247 } 248 }
248 249
249 bool RenderObject::isBody() const 250 bool RenderObject::isBody() const
250 { 251 {
251 return node() && node()->hasTagName(bodyTag); 252 return isHTMLBodyElement(node());
252 } 253 }
253 254
254 bool RenderObject::isHR() const 255 bool RenderObject::isHR() const
255 { 256 {
256 return node() && node()->hasTagName(hrTag); 257 return isHTMLHRElement(node());
257 } 258 }
258 259
259 bool RenderObject::isLegend() const 260 bool RenderObject::isLegend() const
260 { 261 {
261 return node() && node()->hasTagName(legendTag); 262 return isHTMLLegendElement(node());
262 } 263 }
263 264
264 void RenderObject::setFlowThreadStateIncludingDescendants(FlowThreadState state) 265 void RenderObject::setFlowThreadStateIncludingDescendants(FlowThreadState state)
265 { 266 {
266 for (RenderObject *object = this; object; object = object->nextInPreOrder(th is)) { 267 for (RenderObject *object = this; object; object = object->nextInPreOrder(th is)) {
267 // If object is a fragmentation context it already updated the descendan ts flag accordingly. 268 // If object is a fragmentation context it already updated the descendan ts flag accordingly.
268 if (object->isRenderFlowThread()) 269 if (object->isRenderFlowThread())
269 continue; 270 continue;
270 ASSERT(state != object->flowThreadState()); 271 ASSERT(state != object->flowThreadState());
271 object->setFlowThreadState(state); 272 object->setFlowThreadState(state);
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 2468
2468 if (view) 2469 if (view)
2469 *view = const_cast<RenderView*>(toRenderView(o)); 2470 *view = const_cast<RenderView*>(toRenderView(o));
2470 2471
2471 return true; 2472 return true;
2472 } 2473 }
2473 2474
2474 RenderObject* RenderObject::rendererForRootBackground() 2475 RenderObject* RenderObject::rendererForRootBackground()
2475 { 2476 {
2476 ASSERT(isRoot()); 2477 ASSERT(isRoot());
2477 if (!hasBackground() && node() && node()->hasTagName(htmlTag)) { 2478 if (!hasBackground() && isHTMLHtmlElement(node())) {
2478 // Locate the <body> element using the DOM. This is easier than trying 2479 // Locate the <body> element using the DOM. This is easier than trying
2479 // to crawl around a render tree with potential :before/:after content a nd 2480 // to crawl around a render tree with potential :before/:after content a nd
2480 // anonymous blocks created by inline <body> tags etc. We can locate the <body> 2481 // anonymous blocks created by inline <body> tags etc. We can locate the <body>
2481 // render object very easily via the DOM. 2482 // render object very easily via the DOM.
2482 HTMLElement* body = document().body(); 2483 HTMLElement* body = document().body();
2483 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body- >renderer() : 0; 2484 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body- >renderer() : 0;
2484 if (bodyObject) 2485 if (bodyObject)
2485 return bodyObject; 2486 return bodyObject;
2486 } 2487 }
2487 2488
2488 return this; 2489 return this;
2489 } 2490 }
2490 2491
2491 RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const 2492 RespectImageOrientationEnum RenderObject::shouldRespectImageOrientation() const
2492 { 2493 {
2493 // Respect the image's orientation if it's being used as a full-page image o r it's 2494 // Respect the image's orientation if it's being used as a full-page image o r it's
2494 // an <img> and the setting to respect it everywhere is set. 2495 // an <img> and the setting to respect it everywhere is set.
2495 return document().isImageDocument() 2496 return document().isImageDocument()
2496 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && node() && node()->hasTagName(HTMLNames::imgTag)) ? RespectImageOr ientation : DoNotRespectImageOrientation; 2497 || (document().settings() && document().settings()->shouldRespectImageOr ientation() && isHTMLImageElement(node())) ? RespectImageOrientation : DoNotResp ectImageOrientation;
2497 } 2498 }
2498 2499
2499 bool RenderObject::hasOutlineAnnotation() const 2500 bool RenderObject::hasOutlineAnnotation() const
2500 { 2501 {
2501 return node() && node()->isLink() && document().printing(); 2502 return node() && node()->isLink() && document().printing();
2502 } 2503 }
2503 2504
2504 bool RenderObject::hasEntirelyFixedBackground() const 2505 bool RenderObject::hasEntirelyFixedBackground() const
2505 { 2506 {
2506 return m_style->hasEntirelyFixedBackground(); 2507 return m_style->hasEntirelyFixedBackground();
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 decorations &= ~TextDecorationLineThrough; 3025 decorations &= ~TextDecorationLineThrough;
3025 linethrough.color = resultColor; 3026 linethrough.color = resultColor;
3026 linethrough.style = resultStyle; 3027 linethrough.style = resultStyle;
3027 } 3028 }
3028 } 3029 }
3029 if (curr->isRubyText()) 3030 if (curr->isRubyText())
3030 return; 3031 return;
3031 curr = curr->parent(); 3032 curr = curr->parent();
3032 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n()) 3033 if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuatio n())
3033 curr = toRenderBlock(curr)->continuation(); 3034 curr = toRenderBlock(curr)->continuation();
3034 } while (curr && decorations && (!quirksMode || !curr->node() || (!curr->nod e()->hasTagName(aTag) && !curr->node()->hasTagName(fontTag)))); 3035 } while (curr && decorations && (!quirksMode || !curr->node() || (!isHTMLAnc horElement(*curr->node()) && !isHTMLFontElement(*curr->node()))));
3035 3036
3036 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element). 3037 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element).
3037 if (decorations && curr) { 3038 if (decorations && curr) {
3038 styleToUse = curr->style(firstlineStyle); 3039 styleToUse = curr->style(firstlineStyle);
3039 resultColor = decorationColor(this, styleToUse); 3040 resultColor = decorationColor(this, styleToUse);
3040 if (decorations & TextDecorationUnderline) { 3041 if (decorations & TextDecorationUnderline) {
3041 underline.color = resultColor; 3042 underline.color = resultColor;
3042 underline.style = resultStyle; 3043 underline.style = resultStyle;
3043 } 3044 }
3044 if (decorations & TextDecorationOverline) { 3045 if (decorations & TextDecorationOverline) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes 3171 // Spec: http://www.w3.org/TR/cssom-view/#offset-attributes
3171 3172
3172 node = ancestor->node(); 3173 node = ancestor->node();
3173 3174
3174 if (!node) 3175 if (!node)
3175 continue; 3176 continue;
3176 3177
3177 if (ancestor->isPositioned()) 3178 if (ancestor->isPositioned())
3178 break; 3179 break;
3179 3180
3180 if (node->hasTagName(bodyTag)) 3181 if (isHTMLBodyElement(*node))
3181 break; 3182 break;
3182 3183
3183 if (!isPositioned() && (node->hasTagName(tableTag) || node->hasTagName(t dTag) || node->hasTagName(thTag))) 3184 if (!isPositioned() && (isHTMLTableElement(*node) || isHTMLTableCellElem ent(*node)))
3184 break; 3185 break;
3185 3186
3186 // Webkit specific extension where offsetParent stops at zoom level chan ges. 3187 // Webkit specific extension where offsetParent stops at zoom level chan ges.
3187 if (effectiveZoom != ancestor->style()->effectiveZoom()) 3188 if (effectiveZoom != ancestor->style()->effectiveZoom())
3188 break; 3189 break;
3189 } 3190 }
3190 3191
3191 return node && node->isElementNode() ? toElement(node) : 0; 3192 return node && node->isElementNode() ? toElement(node) : 0;
3192 } 3193 }
3193 3194
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 { 3352 {
3352 if (object1) { 3353 if (object1) {
3353 const WebCore::RenderObject* root = object1; 3354 const WebCore::RenderObject* root = object1;
3354 while (root->parent()) 3355 while (root->parent())
3355 root = root->parent(); 3356 root = root->parent();
3356 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); 3357 root->showRenderTreeAndMark(object1, "*", object2, "-", 0);
3357 } 3358 }
3358 } 3359 }
3359 3360
3360 #endif 3361 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMeter.cpp ('k') | Source/core/rendering/RenderProgress.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698