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

Side by Side Diff: Source/core/css/StyleSheetContents.cpp

Issue 157853002: Revert of Use removeFontFace to avoid resetting fontSelector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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/css/StyleSheetContents.h ('k') | Source/core/dom/DocumentStyleSheetCollection.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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/css/StyleSheetContents.h" 22 #include "core/css/StyleSheetContents.h"
23 23
24 #include "core/css/parser/BisonCSSParser.h" 24 #include "core/css/parser/BisonCSSParser.h"
25 #include "core/css/CSSStyleSheet.h" 25 #include "core/css/CSSStyleSheet.h"
26 #include "core/css/MediaList.h" 26 #include "core/css/MediaList.h"
27 #include "core/css/StylePropertySet.h" 27 #include "core/css/StylePropertySet.h"
28 #include "core/css/StyleRule.h" 28 #include "core/css/StyleRule.h"
29 #include "core/css/StyleRuleImport.h" 29 #include "core/css/StyleRuleImport.h"
30 #include "core/dom/Document.h" 30 #include "core/css/resolver/StyleResolver.h"
31 #include "core/dom/Node.h" 31 #include "core/dom/Node.h"
32 #include "core/dom/StyleEngine.h" 32 #include "core/dom/StyleEngine.h"
33 #include "core/fetch/CSSStyleSheetResource.h" 33 #include "core/fetch/CSSStyleSheetResource.h"
34 #include "core/frame/UseCounter.h" 34 #include "core/frame/UseCounter.h"
35 #include "platform/TraceEvent.h" 35 #include "platform/TraceEvent.h"
36 #include "platform/weborigin/SecurityOrigin.h" 36 #include "platform/weborigin/SecurityOrigin.h"
37 #include "wtf/Deque.h" 37 #include "wtf/Deque.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 // Inserting @import rule after a non-import rule is not allowed. 259 // Inserting @import rule after a non-import rule is not allowed.
260 if (rule->isImportRule()) 260 if (rule->isImportRule())
261 return false; 261 return false;
262 262
263 if (rule->isMediaRule()) 263 if (rule->isMediaRule())
264 setHasMediaQueries(); 264 setHasMediaQueries();
265 265
266 childVectorIndex -= m_importRules.size(); 266 childVectorIndex -= m_importRules.size();
267 267
268 if (rule->isFontFaceRule())
269 setHasFontFaceRule(true);
270 m_childRules.insert(childVectorIndex, rule); 268 m_childRules.insert(childVectorIndex, rule);
271 return true; 269 return true;
272 } 270 }
273 271
274 void StyleSheetContents::wrapperDeleteRule(unsigned index) 272 void StyleSheetContents::wrapperDeleteRule(unsigned index)
275 { 273 {
276 ASSERT(m_isMutable); 274 ASSERT(m_isMutable);
277 ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount()); 275 ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount());
278 276
279 unsigned childVectorIndex = index; 277 unsigned childVectorIndex = index;
280 if (hasCharsetRule()) { 278 if (hasCharsetRule()) {
281 if (childVectorIndex == 0) { 279 if (childVectorIndex == 0) {
282 clearCharsetRule(); 280 clearCharsetRule();
283 return; 281 return;
284 } 282 }
285 --childVectorIndex; 283 --childVectorIndex;
286 } 284 }
287 if (childVectorIndex < m_importRules.size()) { 285 if (childVectorIndex < m_importRules.size()) {
288 m_importRules[childVectorIndex]->clearParentStyleSheet(); 286 m_importRules[childVectorIndex]->clearParentStyleSheet();
289 if (m_importRules[childVectorIndex]->isFontFaceRule())
290 notifyRemoveFontFaceRule(toStyleRuleFontFace(m_importRules[childVect orIndex].get()));
291 m_importRules.remove(childVectorIndex); 287 m_importRules.remove(childVectorIndex);
292 return; 288 return;
293 } 289 }
294 childVectorIndex -= m_importRules.size(); 290 childVectorIndex -= m_importRules.size();
295 291
296 if (m_childRules[childVectorIndex]->isFontFaceRule())
297 notifyRemoveFontFaceRule(toStyleRuleFontFace(m_childRules[childVectorInd ex].get()));
298 m_childRules.remove(childVectorIndex); 292 m_childRules.remove(childVectorIndex);
299 } 293 }
300 294
301 void StyleSheetContents::parserAddNamespace(const AtomicString& prefix, const At omicString& uri) 295 void StyleSheetContents::parserAddNamespace(const AtomicString& prefix, const At omicString& uri)
302 { 296 {
303 if (uri.isNull() || prefix.isNull()) 297 if (uri.isNull() || prefix.isNull())
304 return; 298 return;
305 PrefixNamespaceURIMap::AddResult result = m_namespaces.add(prefix, uri); 299 PrefixNamespaceURIMap::AddResult result = m_namespaces.add(prefix, uri);
306 if (result.isNewEntry) 300 if (result.isNewEntry)
307 return; 301 return;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 566
573 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures. 567 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures.
574 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. 568 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet.
575 for (size_t i = 0; i < m_clients.size(); ++i) { 569 for (size_t i = 0; i < m_clients.size(); ++i) {
576 if (Document* document = m_clients[i]->ownerDocument()) 570 if (Document* document = m_clients[i]->ownerDocument())
577 document->styleEngine()->clearResolver(); 571 document->styleEngine()->clearResolver();
578 } 572 }
579 m_ruleSet.clear(); 573 m_ruleSet.clear();
580 } 574 }
581 575
582 void StyleSheetContents::notifyRemoveFontFaceRule(const StyleRuleFontFace* fontF aceRule)
583 {
584 StyleSheetContents* root = rootStyleSheet();
585 if (root->m_clients.isEmpty())
586 return;
587
588 for (unsigned i = 0; i < root->m_clients.size(); ++i) {
589 if (Node* ownerNode = root->m_clients[0]->ownerNode())
590 ownerNode->document().styleEngine()->removeFontFaceRules(Vector<cons t StyleRuleFontFace*>(1, fontFaceRule));
591 }
592 }
593
594 static void findFontFaceRulesFromRules(const Vector<RefPtr<StyleRuleBase> >& rul es, Vector<const StyleRuleFontFace*>& fontFaceRules)
595 {
596 for (unsigned i = 0; i < rules.size(); ++i) {
597 StyleRuleBase* rule = rules[i].get();
598
599 if (rule->isFontFaceRule()) {
600 fontFaceRules.append(toStyleRuleFontFace(rule));
601 } else if (rule->isMediaRule()) {
602 StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule);
603 // We cannot know whether the media rule matches or not, but
604 // for safety, remove @font-face in the media rule (if exists).
605 findFontFaceRulesFromRules(mediaRule->childRules(), fontFaceRules);
606 }
607 }
608 }
609
610 void StyleSheetContents::findFontFaceRules(Vector<const StyleRuleFontFace*>& fon tFaceRules)
611 {
612 for (unsigned i = 0; i < m_importRules.size(); ++i) {
613 if (!m_importRules[i]->styleSheet())
614 continue;
615 m_importRules[i]->styleSheet()->findFontFaceRules(fontFaceRules);
616 }
617
618 findFontFaceRulesFromRules(childRules(), fontFaceRules);
619 }
620 576
621 } 577 }
OLDNEW
« no previous file with comments | « Source/core/css/StyleSheetContents.h ('k') | Source/core/dom/DocumentStyleSheetCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698