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

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

Issue 82583005: Use removeFontFace to avoid resetting fontSelector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Modified resetFontSelector Created 6 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 | Annotate | Revision Log
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/css/resolver/StyleResolver.h" 30 #include "core/dom/Document.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);
268 m_childRules.insert(childVectorIndex, rule); 270 m_childRules.insert(childVectorIndex, rule);
269 return true; 271 return true;
270 } 272 }
271 273
272 void StyleSheetContents::wrapperDeleteRule(unsigned index) 274 void StyleSheetContents::wrapperDeleteRule(unsigned index)
273 { 275 {
274 ASSERT(m_isMutable); 276 ASSERT(m_isMutable);
275 ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount()); 277 ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount());
276 278
277 unsigned childVectorIndex = index; 279 unsigned childVectorIndex = index;
278 if (hasCharsetRule()) { 280 if (hasCharsetRule()) {
279 if (childVectorIndex == 0) { 281 if (childVectorIndex == 0) {
280 clearCharsetRule(); 282 clearCharsetRule();
281 return; 283 return;
282 } 284 }
283 --childVectorIndex; 285 --childVectorIndex;
284 } 286 }
285 if (childVectorIndex < m_importRules.size()) { 287 if (childVectorIndex < m_importRules.size()) {
286 m_importRules[childVectorIndex]->clearParentStyleSheet(); 288 m_importRules[childVectorIndex]->clearParentStyleSheet();
289 if (m_importRules[childVectorIndex]->isFontFaceRule())
290 notifyRemoveFontFaceRule(toStyleRuleFontFace(m_importRules[childVect orIndex].get()));
287 m_importRules.remove(childVectorIndex); 291 m_importRules.remove(childVectorIndex);
288 return; 292 return;
289 } 293 }
290 childVectorIndex -= m_importRules.size(); 294 childVectorIndex -= m_importRules.size();
291 295
296 if (m_childRules[childVectorIndex]->isFontFaceRule())
297 notifyRemoveFontFaceRule(toStyleRuleFontFace(m_childRules[childVectorInd ex].get()));
292 m_childRules.remove(childVectorIndex); 298 m_childRules.remove(childVectorIndex);
293 } 299 }
294 300
295 void StyleSheetContents::parserAddNamespace(const AtomicString& prefix, const At omicString& uri) 301 void StyleSheetContents::parserAddNamespace(const AtomicString& prefix, const At omicString& uri)
296 { 302 {
297 if (uri.isNull() || prefix.isNull()) 303 if (uri.isNull() || prefix.isNull())
298 return; 304 return;
299 PrefixNamespaceURIMap::AddResult result = m_namespaces.add(prefix, uri); 305 PrefixNamespaceURIMap::AddResult result = m_namespaces.add(prefix, uri);
300 if (result.isNewEntry) 306 if (result.isNewEntry)
301 return; 307 return;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 570
565 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures. 571 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures.
566 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. 572 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet.
567 for (size_t i = 0; i < m_clients.size(); ++i) { 573 for (size_t i = 0; i < m_clients.size(); ++i) {
568 if (Document* document = m_clients[i]->ownerDocument()) 574 if (Document* document = m_clients[i]->ownerDocument())
569 document->styleEngine()->clearResolver(); 575 document->styleEngine()->clearResolver();
570 } 576 }
571 m_ruleSet.clear(); 577 m_ruleSet.clear();
572 } 578 }
573 579
580 void StyleSheetContents::notifyRemoveFontFaceRule(const StyleRuleFontFace* fontF aceRule)
581 {
582 StyleSheetContents* root = rootStyleSheet();
583 if (root->m_clients.isEmpty())
584 return;
585
586 for (unsigned i = 0; i < root->m_clients.size(); ++i) {
587 if (Node* ownerNode = root->m_clients[0]->ownerNode())
588 ownerNode->document().styleEngine()->removeFontFaceRules(Vector<cons t StyleRuleFontFace*>(1, fontFaceRule));
589 }
590 }
591
592 static void findFontFaceRulesFromRules(const Vector<RefPtr<StyleRuleBase> >& rul es, Vector<const StyleRuleFontFace*>& fontFaceRules)
593 {
594 for (unsigned i = 0; i < rules.size(); ++i) {
595 StyleRuleBase* rule = rules[i].get();
596
597 if (rule->isFontFaceRule()) {
598 fontFaceRules.append(toStyleRuleFontFace(rule));
599 } else if (rule->isMediaRule()) {
600 StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule);
601 // We cannot know whether the media rule matches or not, but
602 // for safety, remove @font-face in the media rule (if exists).
603 findFontFaceRulesFromRules(mediaRule->childRules(), fontFaceRules);
604 }
605 }
606 }
607
608 void StyleSheetContents::findFontFaceRules(Vector<const StyleRuleFontFace*>& fon tFaceRules)
609 {
610 for (unsigned i = 0; i < m_importRules.size(); ++i) {
611 if (!m_importRules[i]->styleSheet())
612 continue;
613 m_importRules[i]->styleSheet()->findFontFaceRules(fontFaceRules);
614 }
615
616 findFontFaceRulesFromRules(childRules(), fontFaceRules);
617 }
574 618
575 } 619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698