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

Side by Side Diff: sky/engine/core/dom/TreeScope.cpp

Issue 852703002: Merge StyleSheetCollection into ScopedStyleResolver. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/dom/TreeScope.h ('k') | sky/engine/core/html/HTMLStyleElement.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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 #include "sky/engine/config.h" 27 #include "sky/engine/config.h"
28 #include "sky/engine/core/dom/TreeScope.h" 28 #include "sky/engine/core/dom/TreeScope.h"
29 29
30 #include "gen/sky/core/HTMLNames.h" 30 #include "gen/sky/core/HTMLNames.h"
31 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h" 31 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h"
32 #include "sky/engine/core/dom/ContainerNode.h" 32 #include "sky/engine/core/dom/ContainerNode.h"
33 #include "sky/engine/core/dom/Document.h" 33 #include "sky/engine/core/dom/Document.h"
34 #include "sky/engine/core/dom/Element.h" 34 #include "sky/engine/core/dom/Element.h"
35 #include "sky/engine/core/dom/ElementTraversal.h" 35 #include "sky/engine/core/dom/ElementTraversal.h"
36 #include "sky/engine/core/dom/NodeRenderStyle.h" 36 #include "sky/engine/core/dom/NodeRenderStyle.h"
37 #include "sky/engine/core/dom/StyleSheetCollection.h"
38 #include "sky/engine/core/dom/TreeScopeAdopter.h" 37 #include "sky/engine/core/dom/TreeScopeAdopter.h"
39 #include "sky/engine/core/dom/shadow/ElementShadow.h" 38 #include "sky/engine/core/dom/shadow/ElementShadow.h"
40 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 39 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
41 #include "sky/engine/core/editing/DOMSelection.h" 40 #include "sky/engine/core/editing/DOMSelection.h"
42 #include "sky/engine/core/events/EventPath.h" 41 #include "sky/engine/core/events/EventPath.h"
43 #include "sky/engine/core/frame/FrameView.h" 42 #include "sky/engine/core/frame/FrameView.h"
44 #include "sky/engine/core/frame/LocalFrame.h" 43 #include "sky/engine/core/frame/LocalFrame.h"
45 #include "sky/engine/core/html/HTMLAnchorElement.h" 44 #include "sky/engine/core/html/HTMLAnchorElement.h"
46 #include "sky/engine/core/page/FocusController.h" 45 #include "sky/engine/core/page/FocusController.h"
47 #include "sky/engine/core/page/Page.h" 46 #include "sky/engine/core/page/Page.h"
48 #include "sky/engine/core/rendering/HitTestResult.h" 47 #include "sky/engine/core/rendering/HitTestResult.h"
49 #include "sky/engine/core/rendering/RenderView.h" 48 #include "sky/engine/core/rendering/RenderView.h"
50 #include "sky/engine/wtf/Vector.h" 49 #include "sky/engine/wtf/Vector.h"
51 50
52 namespace blink { 51 namespace blink {
53 52
54 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) 53 TreeScope::TreeScope(ContainerNode& rootNode, Document& document)
55 : m_rootNode(&rootNode) 54 : m_rootNode(&rootNode)
56 , m_document(&document) 55 , m_document(&document)
57 , m_parentTreeScope(&document) 56 , m_parentTreeScope(&document)
58 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) 57 , m_scopedStyleResolver(ScopedStyleResolver::create(*this))
59 , m_styleSheets(StyleSheetCollection::create(*this))
60 , m_guardRefCount(0) 58 , m_guardRefCount(0)
61 { 59 {
62 ASSERT(rootNode != document); 60 ASSERT(rootNode != document);
63 m_parentTreeScope->guardRef(); 61 m_parentTreeScope->guardRef();
64 m_rootNode->setTreeScope(this); 62 m_rootNode->setTreeScope(this);
65 } 63 }
66 64
67 TreeScope::TreeScope(Document& document) 65 TreeScope::TreeScope(Document& document)
68 : m_rootNode(document) 66 : m_rootNode(document)
69 , m_document(&document) 67 , m_document(&document)
70 , m_parentTreeScope(nullptr) 68 , m_parentTreeScope(nullptr)
71 , m_scopedStyleResolver(ScopedStyleResolver::create(*this)) 69 , m_scopedStyleResolver(ScopedStyleResolver::create(*this))
72 , m_styleSheets(StyleSheetCollection::create(*this))
73 , m_guardRefCount(0) 70 , m_guardRefCount(0)
74 { 71 {
75 m_rootNode->setTreeScope(this); 72 m_rootNode->setTreeScope(this);
76 } 73 }
77 74
78 TreeScope::~TreeScope() 75 TreeScope::~TreeScope()
79 { 76 {
80 ASSERT(!m_guardRefCount); 77 ASSERT(!m_guardRefCount);
81 m_rootNode->setTreeScope(0); 78 m_rootNode->setTreeScope(0);
82 79
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 RenderStyle* style = element->renderStyle(); 393 RenderStyle* style = element->renderStyle();
397 if (style && style->hasViewportUnits()) 394 if (style && style->hasViewportUnits())
398 element->setNeedsStyleRecalc(LocalStyleChange); 395 element->setNeedsStyleRecalc(LocalStyleChange);
399 } 396 }
400 } 397 }
401 398
402 bool TreeScope::hasSameStyles(TreeScope& other) 399 bool TreeScope::hasSameStyles(TreeScope& other)
403 { 400 {
404 if (this == &other) 401 if (this == &other)
405 return true; 402 return true;
406 const Vector<RefPtr<blink::CSSStyleSheet> >& list = styleSheets().activeAuth orStyleSheets(); 403 const Vector<RefPtr<blink::CSSStyleSheet> >& list = scopedStyleResolver().au thorStyleSheets();
407 const Vector<RefPtr<blink::CSSStyleSheet> >& otherList = other.styleSheets() .activeAuthorStyleSheets(); 404 const Vector<RefPtr<blink::CSSStyleSheet> >& otherList = other.scopedStyleRe solver().authorStyleSheets();
408 405
409 if (list.size() != otherList.size()) 406 if (list.size() != otherList.size())
410 return false; 407 return false;
411 408
412 for (size_t i = 0; i < list.size(); i++) { 409 for (size_t i = 0; i < list.size(); i++) {
413 if (list[i]->contents() != otherList[i]->contents()) 410 if (list[i]->contents() != otherList[i]->contents())
414 return false; 411 return false;
415 } 412 }
416 413
417 return true; 414 return true;
418 } 415 }
419 416
420 } // namespace blink 417 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/TreeScope.h ('k') | sky/engine/core/html/HTMLStyleElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698