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

Side by Side Diff: third_party/WebKit/Source/core/html/track/vtt/VTTRegion.cpp

Issue 1844223002: Literal AtomicString construction can rely on strlen optimization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void VTTRegion::setViewportAnchorY(double value, ExceptionState& exceptionState) 149 void VTTRegion::setViewportAnchorY(double value, ExceptionState& exceptionState)
150 { 150 {
151 if (isNonPercentage(value, "viewportAnchorY", exceptionState)) 151 if (isNonPercentage(value, "viewportAnchorY", exceptionState))
152 return; 152 return;
153 153
154 m_viewportAnchor.setY(value); 154 m_viewportAnchor.setY(value);
155 } 155 }
156 156
157 const AtomicString VTTRegion::scroll() const 157 const AtomicString VTTRegion::scroll() const
158 { 158 {
159 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS tring::ConstructFromLiteral)); 159 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up"));
160 160
161 if (m_scroll) 161 if (m_scroll)
162 return upScrollValueKeyword; 162 return upScrollValueKeyword;
163 163
164 return ""; 164 return "";
165 } 165 }
166 166
167 void VTTRegion::setScroll(const AtomicString& value, ExceptionState& exceptionSt ate) 167 void VTTRegion::setScroll(const AtomicString& value, ExceptionState& exceptionSt ate)
168 { 168 {
169 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS tring::ConstructFromLiteral)); 169 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up"));
170 170
171 if (value != emptyString() && value != upScrollValueKeyword) { 171 if (value != emptyString() && value != upScrollValueKeyword) {
172 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid. The 'scroll' property must be either the empty string, o r 'up'."); 172 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid. The 'scroll' property must be either the empty string, o r 'up'.");
173 return; 173 return;
174 } 174 }
175 175
176 m_scroll = value == upScrollValueKeyword; 176 m_scroll = value == upScrollValueKeyword;
177 } 177 }
178 178
179 void VTTRegion::updateParametersFromRegion(VTTRegion* region) 179 void VTTRegion::updateParametersFromRegion(VTTRegion* region)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return None; 231 return None;
232 } 232 }
233 233
234 static inline bool parsedEntireRun(const VTTScanner& input, const VTTScanner::Ru n& run) 234 static inline bool parsedEntireRun(const VTTScanner& input, const VTTScanner::Ru n& run)
235 { 235 {
236 return input.isAt(run.end()); 236 return input.isAt(run.end());
237 } 237 }
238 238
239 void VTTRegion::parseSettingValue(RegionSetting setting, VTTScanner& input) 239 void VTTRegion::parseSettingValue(RegionSetting setting, VTTScanner& input)
240 { 240 {
241 DEFINE_STATIC_LOCAL(const AtomicString, scrollUpValueKeyword, ("up", AtomicS tring::ConstructFromLiteral)); 241 DEFINE_STATIC_LOCAL(const AtomicString, scrollUpValueKeyword, ("up"));
242 242
243 VTTScanner::Run valueRun = input.collectUntil<VTTParser::isASpace>(); 243 VTTScanner::Run valueRun = input.collectUntil<VTTParser::isASpace>();
244 244
245 switch (setting) { 245 switch (setting) {
246 case Id: { 246 case Id: {
247 String stringValue = input.extractString(valueRun); 247 String stringValue = input.extractString(valueRun);
248 if (stringValue.find("-->") == kNotFound) 248 if (stringValue.find("-->") == kNotFound)
249 m_id = stringValue; 249 m_id = stringValue;
250 break; 250 break;
251 } 251 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 case None: 290 case None:
291 break; 291 break;
292 } 292 }
293 293
294 input.skipRun(valueRun); 294 input.skipRun(valueRun);
295 } 295 }
296 296
297 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId() 297 const AtomicString& VTTRegion::textTrackCueContainerShadowPseudoId()
298 { 298 {
299 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerPseudoId, 299 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerPseudoId,
300 ("-webkit-media-text-track-region-container", AtomicString::ConstructFro mLiteral)); 300 ("-webkit-media-text-track-region-container"));
301 301
302 return trackRegionCueContainerPseudoId; 302 return trackRegionCueContainerPseudoId;
303 } 303 }
304 304
305 const AtomicString& VTTRegion::textTrackCueContainerScrollingClass() 305 const AtomicString& VTTRegion::textTrackCueContainerScrollingClass()
306 { 306 {
307 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerScrollingClas s, 307 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionCueContainerScrollingClas s,
308 ("scrolling", AtomicString::ConstructFromLiteral)); 308 ("scrolling"));
309 309
310 return trackRegionCueContainerScrollingClass; 310 return trackRegionCueContainerScrollingClass;
311 } 311 }
312 312
313 const AtomicString& VTTRegion::textTrackRegionShadowPseudoId() 313 const AtomicString& VTTRegion::textTrackRegionShadowPseudoId()
314 { 314 {
315 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionShadowPseudoId, 315 DEFINE_STATIC_LOCAL(const AtomicString, trackRegionShadowPseudoId,
316 ("-webkit-media-text-track-region", AtomicString::ConstructFromLiteral)) ; 316 ("-webkit-media-text-track-region"));
317 317
318 return trackRegionShadowPseudoId; 318 return trackRegionShadowPseudoId;
319 } 319 }
320 320
321 PassRefPtrWillBeRawPtr<HTMLDivElement> VTTRegion::getDisplayTree(Document& docum ent) 321 PassRefPtrWillBeRawPtr<HTMLDivElement> VTTRegion::getDisplayTree(Document& docum ent)
322 { 322 {
323 if (!m_regionDisplayTree) { 323 if (!m_regionDisplayTree) {
324 m_regionDisplayTree = HTMLDivElement::create(document); 324 m_regionDisplayTree = HTMLDivElement::create(document);
325 prepareRegionDisplayTree(); 325 prepareRegionDisplayTree();
326 } 326 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 469 }
470 470
471 DEFINE_TRACE(VTTRegion) 471 DEFINE_TRACE(VTTRegion)
472 { 472 {
473 visitor->trace(m_cueContainer); 473 visitor->trace(m_cueContainer);
474 visitor->trace(m_regionDisplayTree); 474 visitor->trace(m_regionDisplayTree);
475 visitor->trace(m_track); 475 visitor->trace(m_track);
476 } 476 }
477 477
478 } // namespace blink 478 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698