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

Side by Side Diff: Source/core/layout/LayoutVTTCue.cpp

Issue 1314613002: Drop LayoutVTTCue::adjustForTopAndBottomMarginBorderAndPadding (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Drop seagulls. Created 5 years, 4 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/layout/LayoutVTTCue.h ('k') | no next file » | 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) 2012 Victor Carbune (victor@rosedu.org) 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // position to their current position, and then jump to the step labeled 266 // position to their current position, and then jump to the step labeled
267 // done positioning below. If there are multiple such positions that are 267 // done positioning below. If there are multiple such positions that are
268 // equidistant from their current position, use the highest one amongst 268 // equidistant from their current position, use the highest one amongst
269 // them; if there are several at that height, then use the leftmost one 269 // them; if there are several at that height, then use the leftmost one
270 // amongst them. 270 // amongst them.
271 271
272 // 5. Otherwise, jump to the step labeled done positioning below. (The 272 // 5. Otherwise, jump to the step labeled done positioning below. (The
273 // boxes will unfortunately overlap.) 273 // boxes will unfortunately overlap.)
274 } 274 }
275 275
276 void LayoutVTTCue::adjustForTopAndBottomMarginBorderAndPadding()
277 {
278 // Accommodate extra top and bottom padding, border or margin.
279 // Note: this is supported only for internal UA styling, not through the cue selector.
280 if (!hasInlineDirectionBordersPaddingOrMargin())
281 return;
282 IntRect containerRect = containingBlock()->absoluteBoundingBoxRect();
283 IntRect cueRect = absoluteBoundingBoxRect();
284
285 int topOverflow = cueRect.y() - containerRect.y();
286 int bottomOverflow = containerRect.y() + containerRect.height() - cueRect.y( ) - cueRect.height();
287
288 int adjustment = 0;
289 if (topOverflow < 0)
290 adjustment = -topOverflow;
291 else if (bottomOverflow < 0)
292 adjustment = bottomOverflow;
293
294 if (!adjustment)
295 return;
296
297 setY(location().y() + adjustment);
298 }
299
300 void LayoutVTTCue::layout() 276 void LayoutVTTCue::layout()
301 { 277 {
302 LayoutBlockFlow::layout(); 278 LayoutBlockFlow::layout();
303 279
304 ASSERT(firstChild()); 280 ASSERT(firstChild());
305 281
306 LayoutState state(*this, locationOffset()); 282 LayoutState state(*this, locationOffset());
307 283
308 // Determine the area covered by the media controls, if any. If the controls 284 // Determine the area covered by the media controls, if any. If the controls
309 // are present, they are the next sibling of the text track container, which 285 // are present, they are the next sibling of the text track container, which
310 // is our parent. (LayoutMedia ensures that the media controls are laid out 286 // is our parent. (LayoutMedia ensures that the media controls are laid out
311 // before text tracks, so that the layout is up-to-date here.) 287 // before text tracks, so that the layout is up-to-date here.)
312 ASSERT(parent()->node()->isTextTrackContainer()); 288 ASSERT(parent()->node()->isTextTrackContainer());
313 IntRect controlsRect; 289 IntRect controlsRect;
314 if (LayoutObject* parentSibling = parent()->nextSibling()) { 290 if (LayoutObject* parentSibling = parent()->nextSibling()) {
315 // Only a part of the media controls is used for overlap avoidance. 291 // Only a part of the media controls is used for overlap avoidance.
316 MediaControls* controls = toMediaControls(parentSibling->node()); 292 MediaControls* controls = toMediaControls(parentSibling->node());
317 if (LayoutObject* controlsLayout = controls->layoutObjectForTextTrackLay out()) 293 if (LayoutObject* controlsLayout = controls->layoutObjectForTextTrackLay out())
318 controlsRect = controlsLayout->absoluteBoundingBoxRect(); 294 controlsRect = controlsLayout->absoluteBoundingBoxRect();
319 } 295 }
320 296
321 // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13. 297 // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13.
322 if (!std::isnan(m_snapToLinesPosition)) { 298 if (!std::isnan(m_snapToLinesPosition))
323 SnapToLinesLayouter(*this, controlsRect).layout(); 299 SnapToLinesLayouter(*this, controlsRect).layout();
324 300 else
325 adjustForTopAndBottomMarginBorderAndPadding();
326 } else {
327 repositionCueSnapToLinesNotSet(); 301 repositionCueSnapToLinesNotSet();
328 }
329 } 302 }
330 303
331 } // namespace blink 304 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutVTTCue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698